Formula
Time limit:4000/2000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1204 Accepted Submission (s): 415
Problem DescriptionF(N)=(∏I=1NIn−i+1)%1000000007
You were expected to write a program to calculate f (n) when a certain n was given.
Inputmulti test Cases (about 100000), every case contains an integer n-a single line.
Please process to the end of file.
[Technical specification]
n10000000
Outputfor each n,output f (n) in a.
Sample Input2100
Sample Output2148277692: This problem is too card, can only save all the questions, and then order, but the number is too large obviously can not be used as subscript, open a structure to record the subscript, and then discretized subscript, and finally found the subscript in turn output.
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<queue>using namespaceStd;typedefLong LongLL;ConstLL mod =1000000007;structask{LL v; intThe Ori;} ask[200005]; LL a[200005];intCMP (Ask a,ask b) {returna.v<B.V;}intMain () {intN,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(intI=1; i<id;i++) {A[ask[i].ori]=i; } LL CNT=1, ans=1; for(intI=1; i<id; i++) { for(intj=ask[i-1].v+1; j<=ask[i].v; J + +) {CNT= cnt*j%MoD; Ans= ans*cnt%MoD; } A[ask[i].ori]=ans; } for(intI=1; i<id;i++) {printf ("%lld\n", A[i]); }}
Hdu 5139 (Off-line processing + discretized subscript)