阶乘

来源:互联网 发布:数据库的逻辑模型 编辑:程序博客网 时间:2024/04/28 09:49
// 阶乘.cpp : 定义控制台应用程序的入口点。////#include "stdafx.h"#include<iostream>#include<cstdio>using namespace std;#define Mod 100000//int _tmain(int argc, _TCHAR* argv[])int main(){int n, m, Case;cin >> Case;while( Case-- ){cin >> n >> m;long long ans = 1;for( int i = n; i >= 2; --i ){ans *= i;while( ans % 10 == 0 ){ans /= 10;}ans %= Mod;}//cout << ans << endl;for( int i = 0; i < m - 1; ++i ){ans /= 10;}ans = ans % 10;cout << ans << endl;}return 0;}

原创粉丝点击