标签:des style blog http color os io 数据
4 5
24 120
求N!%2009的最大值,n最大10^9;
解题思路:
解题代码:我靠,乍一看数据量挺大的,几秒后反应过来,n>=2009后还要计算个毛线。
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int main(){
while(scanf("%d",&n)!=EOF){
if(n>=2009) printf("0\n");
else{
int ans=1;
for(int i=2;i<=n;i++){
ans=(ans*i)%2009;
}
printf("%d\n",ans);
}
}
return 0;
}
HDU 2674 N!Again (数论-水题),布布扣,bubuko.com
标签:des style blog http color os io 数据
原文地址:http://blog.csdn.net/a1061747415/article/details/38335699