【HDOJ6600】Just Skip The Problem(签到)
题意:询问n!模1e6+7的结果
n<=1e9
思路:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 typedef unsigned int uint; 5 typedef unsigned long long ull; 6 typedef pair<int,int> PII; 7 typedef pair<ll,ll> Pll; 8 typedef vector<int> VI; 9 #define N 110000 10 #define M 1100000 11 #define fi first 12 #define se second 13 #define MP make_pair 14 #define pi acos(-1) 15 #define mem(a,b) memset(a,b,sizeof(a)) 16 #define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++) 17 #define per(i,a,b) for(int i=(int)a;i>=(int)b;i--) 18 #define lowbit(x) x&(-x) 19 #define Rand (rand()*(1<<16)+rand()) 20 #define id(x) ((x)<=B?(x):m-n/(x)+1) 21 #define ls p<<1 22 #define rs p<<1|1 23 24 const int MOD=1e6+3; 25 double eps=1e-6; 26 ll INF=1e14; 27 28 29 int read() 30 { 31 int v=0,f=1; 32 char c=getchar(); 33 while(c<48||57<c) {if(c=='-') f=-1; c=getchar();} 34 while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar(); 35 return v*f; 36 } 37 38 int main() 39 { 40 //freopen("1.in","r",stdin); 41 //freopen("1.out","w",stdout); 42 int n; 43 while(scanf("%d",&n)!=EOF) 44 { 45 ll ans=1; 46 if(n>=MOD) 47 { 48 printf("0\n"); 49 continue; 50 } 51 52 rep(i,1,n) ans=ans*i%MOD; 53 printf("%I64d\n",ans); 54 } 55 return 0; 56 }
null