• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 14,  comments - 11,  trackbacks - 0

            Giving the N, can you tell me the answer of F(N)?

            Input
            Each test case contains a single integer N(1<=N<=10^9). The input is terminated by a set starting with N = 0. This set should not be processed. 

            Output
            For each test case, output on a line the value of the F(N)%2009.

            Sample Input
            1 2 3 0

            Sample Output
            1 7 20

            對于這個題,剛開始想到的是直接暴力模擬,可看到10^9,呵呵,不超,也得拖死哈!這種題,一般都有規律,看到2009,可能就是一個關鍵!答案70%是一個循環,寫好提交,果然不出所料~
            找規律,發現4018=2009*2剛好是一個循環,解決問題!然而真羨慕那個15ms的!代碼如下:
             1 #include<iostream>
             2 int q(int n)
             3 {
             4     if(n==1)return 1;
             5     if (n==2)return 7;
             6     else return (q(n-2)-(n-1)*(n-1)*(n-1)+n*n*n)%2009;
             7 }
             8 int main()
             9 {
            10     int n;
            11     int a[4020];
            12     for (int i=1;i<=4018;i++)
            13     {
            14         a[i]=q(i)%2009;    
            15     }    
            16     while (scanf("%d",&n)&&n!=0)
            17     {
            18           printf("%d\n",a[n%4018]);           
            19     }
            20 return 0;
            21 }
            22 



            posted on 2010-12-29 10:13 路修遠 閱讀(247) 評論(0)  編輯 收藏 引用
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            轉載,請標明出處!謝謝~~

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            文章檔案

            搜索

            •  

            最新評論

            • 1.?re: HDU 2433 最短路
            • @test
              的確這組數據應該輸出20的
            • --YueYueZha
            • 2.?re: HDU 2433 最短路
            • 這方法應該不對。 看下面這組數據
              4 4
              1 2
              2 3
              3 4
              2 4

              畫個圖,刪去最后一條邊 2 4 后的結果應該是20,但是此方法的輸出是19
            • --test
            • 3.?re: HDU 2433 最短路
            • ans = ans + sum_u + sum_v - sum[u] - sum[v],
              這個公式不是很理解啊,不知道博主怎么想的啊,謝謝咯
            • --姜
            • 4.?re: HDU 2433 最短路
            • @attacker
              the i-th line is the new SUM after the i-th road is destroyed
            • --路修遠
            • 5.?re: HDU 2433 最短路
            • 你這樣可以AC????刪除<U,V>不僅改變 u,v最短路啊、、、求解
            • --attacker

            閱讀排行榜

            評論排行榜

            97久久精品国产精品青草| 无码人妻少妇久久中文字幕| 99久久精品国产一区二区| 久久婷婷五月综合色高清 | 日本精品久久久久中文字幕8 | 久久偷看各类wc女厕嘘嘘| 久久精品国产亚洲网站| 热久久国产欧美一区二区精品| 新狼窝色AV性久久久久久| 国产激情久久久久影院小草| 亚洲国产香蕉人人爽成AV片久久| 久久综合九色综合网站| 久久久久国产成人精品亚洲午夜| 久久人人爽人人爽人人AV | 国产欧美一区二区久久| 久久99精品九九九久久婷婷| 精品久久久无码21p发布| 一级做a爰片久久毛片16| 亚洲国产精品无码久久久蜜芽 | 久久精品夜色噜噜亚洲A∨| 久久AV高潮AV无码AV| 久久久人妻精品无码一区| 国产产无码乱码精品久久鸭| 久久婷婷五月综合色奶水99啪| 国产精品无码久久四虎| .精品久久久麻豆国产精品| 久久天天躁夜夜躁狠狠| 久久这里的只有是精品23| 精品久久久久久久中文字幕| 久久er99热精品一区二区| 久久精品国产男包| 免费精品国产日韩热久久| 久久强奷乱码老熟女| 亚洲午夜精品久久久久久人妖| 久久精品无码一区二区三区| 久久精品国产亚洲AV无码麻豆 | 久久精品无码av| 美女久久久久久| 免费久久人人爽人人爽av| yy6080久久| 亚洲AV日韩精品久久久久久|