• <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>

            Why so serious? --[NKU]schindlerlee

            2010-06-08 23:24:36.ural1057 number theory and dp

            2010-06-08 23:24:36.ural1057 number theory and dp 數位類統計問題
            不說了,詳見國家集訓隊2009論文集 14.劉聰 <<淺談數位類統計問題>>
            需要非常注意邊界條件的處理.
            ??1?/*
            ??2??*?SOUR:ural?1057
            ??3??*?ALGO:number?theory?and?binary?tree,?in?other?word?enumerate?the?highest?digit,
            ??4??*??????and?use?dp?to?reduce?calculation.
            ??5??*?DATE:?2010年?06月?08日?星期二?16:44:45?CST
            ??6??*?COMM:
            ??7??*?*/
            ??8?
            ??9?using?namespace?std;
            ?10?#define?pb(x)?push_back(x)
            ?11?#define?X?first
            ?12?#define?Y?second
            ?13?typedef?vector?<?int?>vi;
            ?14?typedef?pair?<?int,?int?>pii;
            ?15?typedef?long?long?LL;
            ?16?template?<class?T>?void?ckmin(T?&a,T?b)?{?if?(a?>?b)?{?a?=?b;?}?}
            ?17?template?<class?T>?void?ckmax(T?&a,T?b)?{?if?(a?<?b)?{?a?=?b;?}?}
            ?18?int?countbit(int?n)?{?return?n?==?0???0?:?1?+?countbit(n?&?(n?-?1));?}
            ?19?
            ?20?const?int?maxint?=?0x7fffffff;
            ?21?const?long?long?max64?=?0x7fffffffffffffffll;
            ?22?int?X,?Y,?K,?B;
            ?23?int?cnt[40][40];
            ?24?
            ?25?void?pre?()
            ?26?{
            ?27???int?i,?j;
            ?28???cnt[0][0]?=?1;
            ?29???for?(i?=?1;i?<=?32;i++)?{
            ?30???????cnt[i][0]?=?cnt[i-1][0];
            ?31???????for?(j?=?1;j?<=?32;j++)?{
            ?32???????????cnt[i][j]?=?cnt[i-1][j]?+?cnt[i-1][j-1];
            ?33???????}
            ?34???}
            ?35?}
            ?36?
            ?37?void?changeBase(int?X,?int?num[],?int?&top)
            ?38?{
            ?39???top?=?1;
            ?40???while?(X?>?0)?{
            ?41???????num[top++]?=?X?%?B;
            ?42???????X?/=?B;
            ?43???}
            ?44?}
            ?45?
            ?46?void?plus_one(int?num[],?int?&top)
            ?47?{
            ?48???int?i,j;
            ?49???for?(i?=?1;i?<=?top;i++)?{
            ?50???????if?(num[i]?==?0)?{
            ?51???????????num[i]?=?1;
            ?52???????????for?(j?=?i?-?1;j?>=?1;j--)?{
            ?53???????????????num[j]?=?0;
            ?54???????????}
            ?55???????????break;
            ?56???????}
            ?57???}
            ?58???if?(i?==?top)?{
            ?59???????top++;
            ?60???}
            ?61?}
            ?62?
            ?63?bool?floor(int?num[],?int?top)
            ?64?{
            ?65???int?i,j;
            ?66???for?(i?=?top?-?1;i?>=?1;i--)?{
            ?67???????if?(num[i]?>?1)?{
            ?68???????????for?(j?=?i;j?>=?1;j--)?{
            ?69???????????????num[j]?=?1;
            ?70???????????}
            ?71???????????break;
            ?72???????}
            ?73???}
            ?74???if?(i?>=?1)?{
            ?75???????return?true;
            ?76???}
            ?77???return?false;
            ?78?}
            ?79?
            ?80?int?num[40],?top;
            ?81?int?proc(int?X,bool?flag?=?false)
            ?82?{
            ?83???memset(num,?0,?sizeof(num));
            ?84???changeBase(X,?num,?top);
            ?85???if?(floor(num,?top)?||?flag)?{
            ?86???????plus_one(num,?top);
            ?87???}
            ?88?
            ?89???int?ans?=?0,?sum?=?0,?i;
            ?90???for?(i?=?top?-?1;i?>=?1;i--)?{
            ?91???????if?(K?>=?sum?&&?num[i]?==?1)?{
            ?92???????????ans?+=?cnt[i-1][K?-?sum];
            ?93???????????sum++;
            ?94???????}
            ?95???}
            ?96???return?ans;
            ?97?}
            ?98?
            ?99?int?main()
            100?{
            101???pre();
            102???int?num[40],?top,?ans;
            103???cin?>>?X?>>?Y?>>?K?>>?B;
            104???ans?=?proc(Y,?1)?-?proc(X);
            105???cout?<<?ans?<<?endl;
            106???return?0;
            107?}


            posted on 2010-06-08 23:31 schindlerlee 閱讀(1551) 評論(0)  編輯 收藏 引用 所屬分類: 解題報告

            曰曰摸天天摸人人看久久久| 99久久国产亚洲综合精品| 久久精品中文字幕无码绿巨人| 日本国产精品久久| 亚洲αv久久久噜噜噜噜噜| 伊人久久大香线蕉av不卡 | 91精品婷婷国产综合久久| 精品久久久久中文字| 久久精品国产一区二区| 91精品国产9l久久久久| 久久久久99精品成人片| 国产高潮国产高潮久久久| 亚洲国产综合久久天堂| 国产 亚洲 欧美 另类 久久| 久久精品中文无码资源站| 国产成人精品久久综合| 91精品国产综合久久久久久| 亚洲精品久久久www| 伊人久久一区二区三区无码| 中文字幕亚洲综合久久2| 久久男人Av资源网站无码软件| 久久久久久久波多野结衣高潮| 中文字幕一区二区三区久久网站| 久久99国产乱子伦精品免费| 无码国内精品久久人妻蜜桃| 三级三级久久三级久久| 久久久久亚洲av无码专区导航| a级毛片无码兔费真人久久| 久久国产精品国语对白| 88久久精品无码一区二区毛片| 久久国产精品99久久久久久老狼| 青草影院天堂男人久久| 丁香五月综合久久激情| 人妻无码精品久久亚瑟影视| 伊人久久大香线蕉综合5g| 欧洲人妻丰满av无码久久不卡 | 久久夜色精品国产噜噜亚洲a| 久久久www免费人成精品| 久久国产精品成人影院| 很黄很污的网站久久mimi色| 国产精品99久久久精品无码|