题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6600
解题心得:这里面最重要的一句,就是你每次询问之后并不会给你答案,最后才给你所有答案,那么你肯定对于二进制位每一位都需要询问,然后对于方法数量再来一个阶乘, 当大于 1 e 6 + 3 1e6+3 1e6+3时阶乘就是是 0 0 0。盲猜这题是今年多校最简单的题。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e6+3;
const int maxn = 1e6+100;
ll num[maxn];
ll init() {
num[0] = 1;
for(int i=1;i<maxn;i++) {
num[i] = (num[i-1] * i) % mod;
}
}
int main() {
init();
ll n;
while(~scanf("%lld", &n)) {
if(n < mod) {
printf("%lld\n", num[n]);
} else {
puts("0");
}
}
return 0;
}