• <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個(gè)數(shù)字的序列,如果全部的相鄰兩個(gè)數(shù)字的差取遍從1到n-1的整數(shù),輸出"Jolly",否則輸出"Not jolly"。比如1 4 2 3,相鄰兩數(shù)之差分別為3 2 1,于是輸出"Jolly"。
            使用一個(gè)bool數(shù)組:如果vis[i]==true,i出現(xiàn)過(guò);否則沒有出現(xiàn)過(guò)。要注意到差值可能很大,因此要判斷是否會(huì)發(fā)生數(shù)組越界。
            以下是我的代碼:
            #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 閱讀(914) 評(píng)論(2)  編輯 收藏 引用 所屬分類: 題目分類:基礎(chǔ)/模擬

            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  回復(fù)  更多評(píng)論
              
            # 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.  回復(fù)  更多評(píng)論
              
            99热成人精品免费久久| 狠狠色丁香久久婷婷综合_中| 99久久香蕉国产线看观香| 国产精品久久新婚兰兰| 国产亚洲欧美精品久久久| 久久国产亚洲精品麻豆| 久久噜噜久久久精品66| 狠狠综合久久综合88亚洲| 久久婷婷久久一区二区三区| 日韩电影久久久被窝网| 久久婷婷成人综合色综合| 久久九九久精品国产| 2022年国产精品久久久久| 久久久久97国产精华液好用吗| 日韩av无码久久精品免费| 久久99精品国产麻豆婷婷| 蜜臀久久99精品久久久久久小说| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 久久久久久久久久久| 久久久国产精品网站| 亚洲精品无码久久久影院相关影片| 日本久久久精品中文字幕| 精品国产乱码久久久久软件| 久久国产高清一区二区三区| 午夜欧美精品久久久久久久| 日日狠狠久久偷偷色综合96蜜桃| A狠狠久久蜜臀婷色中文网| 久久婷婷五月综合国产尤物app| 国产99久久久久久免费看| 国内精品久久久久| 久久AV高清无码| 久久综合给久久狠狠97色| 国产精品99久久久久久宅男小说| 久久精品无码专区免费| 久久天天躁狠狠躁夜夜av浪潮| 久久免费小视频| 国产成人久久精品二区三区| 国产91久久综合| 青青草国产97免久久费观看| 久久久久亚洲av毛片大| 久久久久国产成人精品亚洲午夜|