• <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>
            隨筆-21  評論-10  文章-21  trackbacks-0
            在求每個(gè)置換的不變著色數(shù)時(shí),翻轉(zhuǎn)的置換很容易求,循環(huán)移位的置換暴力找循環(huán)節(jié)(根據(jù)pku 2154跟歐拉數(shù)有關(guān))

             1 #include<iostream>
             2 #include<stdio.h>
             3 using namespace std;
             4 typedef long long ll;
             5 ll ans[24], three[24];
             6 
             7 int c[24];
             8 bool visit[24];
             9 
            10 int xunhuan(int c[], int n) {
            11     int i, j, cnt = 0;
            12     for (i = 0; i < n; i++)
            13         visit[i] = false;
            14     for (i = 0; i < n; i++)
            15         if (!visit[i]) {
            16             cnt++;
            17             j = i;
            18             while (!visit[j]) {
            19                 visit[j] = true;
            20                 j = c[j];
            21             }
            22         }
            23     return cnt;
            24 }
            25 
            26 ll solve_odd(int n) {
            27     int i, j;
            28     ll ans = 0;
            29     for(i = 0; i < n; i++)
            30     {
            31         for(j = 0; j < n; j++)
            32             c[j] = (j+i)%n;
            33         ans += three[ xunhuan(c, n) ];
            34     }
            35     ans += n * three[n/2+1];
            36     return ans / ( 2 * n );
            37 }
            38 
            39 ll solve_even(int n) {
            40     int i, j;
            41     ll ans = 0;
            42     for(i = 0; i < n; i++)
            43     {
            44         for(j = 0; j < n; j++)
            45             c[j] = (j+i)%n;
            46         ans += three[ xunhuan(c, n) ];
            47     }
            48     ans += n / 2 * ( three[n/2+ three[n/2+1] );
            49     return ans / ( 2 * n );
            50 }
            51 
            52 void init() {
            53     int i;
            54     three[0= 1;
            55     for (i = 1; i < 24; i++)
            56         three[i] = three[i - 1]*3;
            57 
            58     for (i = 1; i < 24; i += 2) {
            59         ans[i] = solve_odd(i);
            60         //printf("%lld\n",ans[i]);
            61     }
            62     for (i = 2; i < 24; i += 2) {
            63         ans[i] = solve_even(i);
            64         //printf("%lld\n",ans[i]);
            65     }
            66 }
            67 
            68 int main() {
            69     int i;
            70 //    while(scanf("%d",&i)!=EOF)
            71 //        solve_odd(i);
            72     init();
            73     while (scanf("%d"&i) != EOF) {
            74         if (i == -1)break;
            75         printf("%lld\n", ans[i]);
            76     }
            77 }


            posted on 2009-09-02 16:10 wangzhihao 閱讀(437) 評論(0)  編輯 收藏 引用 所屬分類: math
            久久久久久久国产免费看| 囯产极品美女高潮无套久久久 | 草草久久久无码国产专区| 久久综合九色综合网站| 久久亚洲国产午夜精品理论片| 国产AⅤ精品一区二区三区久久 | 婷婷综合久久中文字幕蜜桃三电影 | 久久中文字幕一区二区| 久久精品国产99久久久香蕉| 国产69精品久久久久观看软件| 亚洲国产精品无码久久| 国产午夜精品理论片久久| 久久久久人妻一区精品果冻| 亚洲精品乱码久久久久久| 久久国产精品成人免费| 久久亚洲视频| 99久久中文字幕| 亚洲精品国精品久久99热| 国产亚洲欧美精品久久久| 久久经典免费视频| 久久久久国产视频电影| 国产亚洲精久久久久久无码| 久久这里的只有是精品23| 青青青国产精品国产精品久久久久| 怡红院日本一道日本久久 | 久久综合给久久狠狠97色| 久久伊人五月天论坛| 久久精品国产亚洲AV电影 | 久久久久久无码Av成人影院| 麻豆久久| 久久午夜综合久久| 久久久久久无码国产精品中文字幕 | 97久久精品国产精品青草| 久久久黄色大片| 久久天天躁夜夜躁狠狠| 亚洲&#228;v永久无码精品天堂久久 | 久久人妻AV中文字幕| 精品国产乱码久久久久久呢| 日韩中文久久| 亚洲国产另类久久久精品| 精品久久亚洲中文无码|