标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1204 Accepted Submission(s): 415
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include <queue> using namespace std; typedef long long LL; const LL mod = 1000000007; struct Ask { LL v; int ori; } ask[200005]; LL a[200005]; int cmp(Ask a,Ask b){ return a.v<b.v; } int main() { int n,id=1; ask[0].v = ask[0].ori = 0; while(scanf("%d",&n)!=EOF) { ask[id].v = n; ask[id].ori = id; id++; } sort(ask+1,ask+id,cmp); for(int i=1;i<id;i++){ a[ask[i].ori] = i; } LL cnt = 1,ans=1; for(int i=1; i<id; i++) { for(int j=ask[i-1].v+1; j<=ask[i].v; j++) { cnt = cnt*j%mod; ans = ans*cnt%mod; } a[ask[i].ori] = ans; } for(int i=1;i<id;i++){ printf("%lld\n",a[i]); } }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5667269.html