日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

hdu 5139 数据的离线处理

發(fā)布時間:2025/3/8 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdu 5139 数据的离线处理 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

所謂的數(shù)據(jù)離線處理,就是將所有的輸入數(shù)據(jù)全部讀入后,在進行統(tǒng)一的操作,這樣當然有好處,比如讓你算好多數(shù)的階層,但是輸入的每個數(shù)是沒有順序的,其實跟可以線性的解決,但是由于沒有順序的輸入,這樣處理的話復雜度就很高,若將輸入的這些數(shù)據(jù)全部先存起來,再排序,然后按從小到大的順序處理。

f(n)=(i=1nin?i+1)%1000000007


You are expected to write a program to calculate f(n) when a certain n is given. InputMulti test cases (about 100000), every case contains an integer n in a single line.
Please process to the end of file.

[Technical Specification]
1n10000000
OutputFor each n,output f(n) in a single line.Sample Input 2 100 Sample 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; }

?

轉載于:https://www.cnblogs.com/ccut-ry/p/7894479.html

總結

以上是生活随笔為你收集整理的hdu 5139 数据的离线处理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。