// 阶乘.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;
}
阶乘
最新推荐文章于 2024-03-24 20:15:03 发布