所謂的數據離線處理,就是將所有的輸入數據全部讀入后,在進行統一的操作,這樣當然有好處,比如讓你算好多數的階層,但是輸入的每個數是沒有順序的,其實跟可以線性的解決,但是由于沒有順序的輸入,這樣處理的話復雜度就很高,若將輸入的這些數據全部先存起來,再排序,然后按從小到大的順序處理。
f(n)=(∏i=1nin?i+1)%1000000007
You are expected to write a program to calculate f(n) when a certain n is given.
Please process to the end of file.
[Technical Specification]
1≤n≤10000000
OutputFor each n,output f(n) in a single line.Sample Input
2 100Sample Output
2 148277692
代碼示例:
struct node
{ll f;ll ans;int id;
}pre[eps];bool cmp1(node a, node b){return a.f < b.f;
}bool cmp2(node a, node b){return a.id < b.id;
}int main() {//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);ll n;int k = 1;while(~scanf("%lld", &n)){pre[k].f = n;pre[k].id = k;k++; }sort(pre+1, pre+k, cmp1);ll s = 1;ll aa = 1;int t = 1;for(ll i = 1; i <= 10000000; i++){s *= i;s %= mod;aa *= s;aa %= mod;while (pre[t].f == i){pre[t++].ans = (aa%mod);}}sort(pre+1, pre+k, cmp2);for(int i = 1; i < k; i++){printf("%lld\n", pre[i].ans);}return 0;
}
?