• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            題目大意:給出n個數字的序列,如果全部的相鄰兩個數字的差取遍從1到n-1的整數,輸出"Jolly",否則輸出"Not jolly"。比如1 4 2 3,相鄰兩數之差分別為3 2 1,于是輸出"Jolly"。
            使用一個bool數組:如果vis[i]==true,i出現過;否則沒有出現過。要注意到差值可能很大,因此要判斷是否會發生數組越界。
            以下是我的代碼:
            #include<stdio.h>
            long Abs(long x)
            {
                
            return (x>0?x:-x);
            }
            bool jolly(bool a[],long n)
            {
                
            for(long i=1;i<=n-1;i++)
                  
            if(!a[i]) return false;
                
            return true;
            }
            int main()
            {
                
            const long maxn=3007;
                
            long n,a[maxn];
                
            bool vis[maxn];
                
            while(scanf("%ld",&n)==1)
                {
                   
            for(long i=1;i<=n;i++) scanf("%ld",&a[i]);
                   
            //  Read In
                   for(long i=1;i<=n;i++) vis[i]=false;
                   
            //  Clear
                   for(long i=1;i<=n-1;i++)
                   {
                      
            long t=Abs(a[i+1]-a[i]);
                      
            if(t<=n-1) vis[t]=true;
                   }
                   
            if(jolly(vis,n)) printf("Jolly\n");
                   
            else printf("Not jolly\n");
                }
            return 0;
            }


            posted on 2010-01-22 12:35 lee1r 閱讀(911) 評論(2)  編輯 收藏 引用 所屬分類: 題目分類:基礎/模擬

            FeedBack:
            # re: UVa 10038 Jolly Jumper
            2010-10-17 23:19 | hossein
            Hi dear !
            can u explain me more about how your program get the data ?
            i can't understand how this program make a difference between sequences that they seperate with a '\n' .

            Thanks dude :D  回復  更多評論
              
            # re: UVa 10038 Jolly Jumper
            2010-10-21 22:07 | Lee1R
            @hossein
            I am glad to receive a message from a foreign friend!
            I guess you are not a Chinese,But I am.
            My English is not so good...

            First,you should know scanf() is a function that will return a value(you can google "scanf()").
            Then,if the program fails to get data in present line, it will try next line automatically until the end of file.
            That's all.  回復  更多評論
              
            伊人久久国产免费观看视频| 久久99精品国产麻豆不卡| 久久这里只有精品首页| 亚洲成av人片不卡无码久久| 日本欧美国产精品第一页久久| 久久久九九有精品国产| 91麻豆国产精品91久久久| 香蕉久久av一区二区三区| 久久久精品国产免大香伊| 国产精品18久久久久久vr| 亚洲国产精品嫩草影院久久| 亚洲а∨天堂久久精品| 国产成人精品久久| 国产精品美女久久久免费| 国产精品成人无码久久久久久| 亚洲国产精品久久66| 久久最新精品国产| 精品久久久久一区二区三区| 久久激情亚洲精品无码?V| 国产精品青草久久久久福利99 | 久久人搡人人玩人妻精品首页| A级毛片无码久久精品免费| 国产成人综合久久精品尤物| 欧美久久综合九色综合| 亚洲午夜无码AV毛片久久| 亚洲精品无码久久千人斩| 久久精品中文騷妇女内射| 久久综合丝袜日本网| 久久青青草原精品国产不卡| 久久精品国产男包| 激情伊人五月天久久综合| 亚洲狠狠久久综合一区77777 | 伊人久久大香线蕉AV一区二区 | jizzjizz国产精品久久| 国产精品久久久久久影院 | 久久久久亚洲精品无码蜜桃| 99国产精品久久| 久久精品国产亚洲Aⅴ蜜臀色欲| 亚洲精品美女久久久久99小说| 久久综合国产乱子伦精品免费| 久久精品国产精品亚洲精品|