标签:des style blog io ar sp for java strong
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 206 Accepted Submission(s): 83
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> using namespace std; #define N 1000005 #define ll __int64 const int mod=1000000007; struct node { int x,id,s; }a[N]; bool cmp1(node a,node b) { return a.x<b.x; } bool cmp2(node a,node b) { return a.id<b.id; } int main() { int m=0,i,j,n; ll s,s2,s3; while(~scanf("%d",&n)) { a[m].id=m; a[m++].x=n; } sort(a,a+m,cmp1); s2=s3=1; s=1; for(i=0,j=2; i<m; i++) { for(; j<=a[i].x; j++) { s=s*j; if(s>=mod) s%=mod; s2=(s*s2)%mod; s3=s2; } a[i].s=s2; } sort(a,a+m,cmp2); for(i=0;i<m;i++) printf("%d\n",a[i].s); return 0; }
标签:des style blog io ar sp for java strong
原文地址:http://www.cnblogs.com/walker11/p/4148947.html