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

            ACM___________________________

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2010年10月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(24)

            隨筆分類(lèi)(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            HDOJ HDU 2053 Switch Game ACM 2053 IN HDU

            Posted on 2010-08-07 15:20 MiYu 閱讀(670) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): ACM ( 模擬 )ACM ( 水題 )
            MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋

            題目地址:
                     http://acm.hdu.edu.cn/showproblem.php?pid=2053
            題目描述:
            Problem Description
            There are many lamps 
            in a line. All of them are off at first. A series of operations are carried out on these lamps. On the i-th operation, the lamps whose numbers are the multiple of i change the condition ( on to off and off to on ).
             

            Input
            Each test 
            case contains only a number n ( 0< n<= 10^5in a line.
             

            Output
            Output the condition of the n
            -th lamp after infinity operations ( 0 - off, 1 - on ).
             

            Sample Input
            1
            5
             

            Sample Output
            1
            0

            Hint
            hint
             

            Consider the second test 
            case:

            The initial condition       : 
            0 0 0 0 0 …
            After the first operation  : 
            1 1 1 1 1 …
            After the second operation : 
            1 0 1 0 1 …
            After the third operation  : 
            1 0 0 0 1 …
            After the fourth operation : 
            1 0 0 1 1 …
            After the fifth operation  : 
            1 0 0 1 0 …

            The later operations cannot change the condition of the fifth lamp any more. So the answer 
            is 0.

            題目分析:
            毫無(wú)疑問(wèn) , 從后面的 Consider the second test case 可以看出, 這是一道模擬題, 根據(jù)題意直接模擬即可!

            代碼如下:
            MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋

            #include 
            <iostream>
            #include 
            <string.h>
            using namespace std;
             
            int arr[100001];
             
            int main()
            {
                
            int n;
                
            while(scanf("%d"&n) != EOF)
                {
                    memset(arr, 
            0sizeof(arr));
                    
            for(int i=1; i<=n; ++i)
                        
            for(int j=1; j<=n&&j*i<=n; ++j)
                            arr[j
            *i] = !arr[j*i];
                    printf(
            "%d\n", arr[n]);
                }
                
            return 0;
            }

            但是這樣非常耗時(shí),  有沒(méi)更簡(jiǎn)單的方法? 當(dāng)然有!  在草稿紙上模擬后得出: 只要是平方數(shù)就是 "1" ,否則為"0" , 所以
            直接哈希,0MS過(guò).

            代碼如下:
            MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋

            #include 
            <iostream>
            using namespace std;
            int F[100001= { 11 };
            int main ()
            {
                
            for ( int i = 2; i * i <= 100000 ; ++ i )
                {
                      F[ i 
            * i ] = 1;
                }
                
            int N;
                
            while ( cin >> N )
                {
                      puts ( F[N] 
            ? "1" : "0" ); 
                }
                
            return 0
            }
            99久久综合国产精品免费| 久久婷婷五月综合国产尤物app | 日产精品久久久一区二区| 伊人久久综合精品无码AV专区| 久久人人爽人人爽人人AV东京热| 久久精品国内一区二区三区| 色综合久久天天综线观看| 欧美亚洲色综久久精品国产| 7国产欧美日韩综合天堂中文久久久久 | 欧美熟妇另类久久久久久不卡 | 日本免费久久久久久久网站| 久久久久波多野结衣高潮| 久久精品一区二区三区中文字幕| 久久久久亚洲AV无码麻豆| 99久久国产亚洲综合精品| 久久久久久狠狠丁香| 日日噜噜夜夜狠狠久久丁香五月| 久久九九久精品国产| 国产99久久精品一区二区| 久久精品一区二区| 2021国内久久精品| 午夜视频久久久久一区 | 国产精品99久久久久久宅男| 久久婷婷国产麻豆91天堂| 新狼窝色AV性久久久久久| 久久精品无码专区免费东京热| 免费精品国产日韩热久久| 久久久久久国产精品无码下载| 久久久久亚洲精品无码网址 | 国产亚州精品女人久久久久久| AAA级久久久精品无码区| 久久精品视频网| 国产99久久久国产精品~~牛 | 久久久无码精品亚洲日韩按摩| 伊人久久大香线蕉av不卡| 精品熟女少妇AV免费久久| 久久人人添人人爽添人人片牛牛 | 日本免费一区二区久久人人澡| 亚洲嫩草影院久久精品| 久久国产精品无码网站| 亚洲?V乱码久久精品蜜桃|