• <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年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

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

            題目地址 :
                     http://acm.hdu.edu.cn/showproblem.php?pid=1982

            PE了N次, 很糾結(jié)的一個(gè)題........  題目如下 :

            Problem Description
            Do you know Kaitou Kid? In the legend, Kaitou Kid is a master of disguise, and can take on the voice and form of anyone. He is not an evil person, but he is on the wrong side of the law. He's the very elusive phantom thief who never miss his prey although he always uses word puzzles to announce his targets before action.

            You are the leader of a museum. Recently, you get several priceless jewels and plan to hold an exhibition. But at the moment, you receive Kid's word puzzle... Fortunately, It seems Kid doesn’t want to trouble you, and his puzzle is very easy. Just a few minutes, You have found the way to solve the puzzle:

            (1) change 1 to 'A', 2 TO 'B',..,26 TO 'Z'
            (2) change '#' to a blank
            (3) ignore the '-' symbol, it just used to separate the numbers in the puzzle

            Input
            The first line of the input contains an integer C which means the number of test cases. Then C lines follow. Each line is a sentence of Kid’s word puzzle which is consisted of '0' ~ '9' , '-' and '#'. The length of each sentence is no longer than 10000.

            Output
            For each case, output the translated text.

            Sample Input
            4 9#23-9-12-12#19-20-5-1-12#1-20#12-5-1-19-20#15-14-5#10-5-23-5-12 1-14-4#12-5-1-22-5#20-8-5#13-21-19-5-21-13#9-14#20#13-9-14-21-20-5-19 1-6-20-5-18#20-8-5#15-16-5-14-9-14-7#15-6#20-8-5#5-24-8-9-2-9-20-9-15-14 7-15-15-4#12-21-3-11

            Sample Output
            I WILL STEAL AT LEAST ONE JEWEL AND LEAVE THE MUSEUM IN T MINUTES AFTER THE OPENING OF THE EXHIBITION GOOD LUCK


            剛開(kāi)始是用的庫(kù)函數(shù) strtok 對(duì)字符串進(jìn)行處理,  直接敲完,沒(méi)有出現(xiàn)錯(cuò)誤, 提交,悲劇開(kāi)始了

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

            #include 
            <iostream>
            #include 
            <cstdlib>
            #include 
            <cstring>
            using namespace std;
            char psw[10005];
            char sym[133];
            void setSym ( )
            {
                 
            int i;
                 
            char ch;
                 
            for ( ch = 'A', i = 1; i <= 26++ i , ++ ch )
                 {
                       sym[i] 
            = ch ;
                 } 

            string prs ( char *psw )
            {
                 
            string str;
                 
            int n = strlen ( psw );
                 
            int num = 0;
                 
            for ( int i = 0; i != n; ++ i )
                 {
                       
            if ( psw[i] != '-' )
                       {
                            num 
            = num * 10 + psw[i] - '0'
                       } 
                       
            else 
                       {
                            
            if ( num != 0 )
                            {
                                 str 
            += sym[num];
                            }
                            num 
            = 0
                       }
                 }
                 
            if ( num != 0 )
                 {
                      str 
            += sym[num];
                 }
                 
            return str;
            }
            int main ()
            {
                setSym ();
                
            int T;
                
            while ( scanf ( "%d\n",&T ) != EOF )
                {
                        
            while ( T -- )
                        {
                                gets ( psw );
                                
            string str;
                                
            char *ptr = strtok ( psw, "#" );
                                
            if ( strlen ( ptr ) != 0 )
                                     str 
            = prs ( ptr ); 
                                
            while ( ptr = strtok ( NULL, "#" ) )
                                {
                                       
            if ( strcmp ( ptr, "" ) != 0 )
                                       {
                                            str 
            += " ";
                                            str 
            += prs ( ptr ); 
                                       }
                                }
                                cout 
            << str << endl;; 
                        }           
                }
                
            return 0
            }

             最后在Ambition 大牛的提示下,成功AC, 因?yàn)閟trtok是忽視被截字符串的個(gè)數(shù)的 "-----######---##-#-#"
            這組數(shù)據(jù)應(yīng)該輸出10個(gè)空格, 而我的代碼值能輸出3個(gè).
            下面的是AC代碼 :
            //MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋

            #include 
            <iostream>
            #include 
            <cstdlib>
            #include 
            <cstring>
            using namespace std;
            char psw[20005];
            char temp[20005];
            char sym[133];
            void setSym ( )
            {
                 
            int i;
                 
            char ch;
                 
            for ( ch = 'A', i = 1; i <= 26++ i , ++ ch )
                 {
                       sym[i] 
            = ch ;
                 } 

            string prs ( char *psw )
            {
                 
            string str;
                 
            int n = strlen ( psw );
                 
            int num = 0;
                 
            for ( int i = 0; i != n; ++ i )
                 {
                       
            if ( psw[i] != '-' )
                       {
                            num 
            = num * 10 + psw[i] - '0'
                       } 
                       
            else 
                       {
                            
            if ( num != 0 )
                            {
                                 str 
            += sym[num];
                            }
                            num 
            = 0
                       }
                 }
                 
            if ( num != 0 )
                 {
                      str 
            += sym[num];
                 }
                 
            return str;
            }
            int main ()
            {
                setSym ();
                
            int T;
                
            while ( scanf ( "%d",&T ) != EOF )
                {
                        getchar ();
                        
            while ( T -- )
                        {
                                gets ( psw );
                                
            int len = strlen ( psw );
                                
            int beg = 0;
                                memset ( temp, 
            '\0'sizeof ( temp ) );
                                
            string str;
                                
            while ( psw[beg] != '\0' )
                                {
                                       
            int i = 0
                                       
            while ( psw[beg] != '#' && psw[beg] != '\0' )
                                       {
                                               temp[i
            ++= psw[beg++]; 
                                       }
                                       temp[i] 
            = '\0';
                                       
            string t = prs ( temp );
                                       
            if ( t.size() != 0 )
                                       {
                                            str 
            += t;
                                            
            if ( psw[beg] == '#' )
                                            {
                                                 str 
            += " "
                                            }  
                                       }
                                       
            else if ( psw[beg] == '#' )
                                       {
                                            str 
            += " "
                                       }
                                       beg 
            ++;
                                }
                                cout 
            << str << endl;
                                memset ( psw, 
            '\0'sizeof ( psw ) );
                        }           
                }
                
            return 0
            }

            弄了一個(gè)下午加一個(gè)晚上才 AC , 是自己把簡(jiǎn)單問(wèn)題想太復(fù)雜了............
            Roowe 神牛代碼 :
            //MiYu原創(chuàng), 轉(zhuǎn)帖請(qǐng)注明 : 轉(zhuǎn)載自 ______________白白の屋

            #include 
            <iostream>
            #include 
            <stdio.h>
            #include 
            <string.h>
            #include 
            <ctype.h>
            using namespace std;
            char str[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
            char s[10001];
            int main()
            {
                
            int T,len,i,num;
                scanf(
            "%d",&T);
                getchar();
                
            while(T--)
                {
                    gets(s);
                    len
            =strlen(s);
                    
            for(i=0;i<len;i++)
                    {
                        
            if(isdigit(s[i]) && isdigit(s[i+1]))
                        {
                            num
            =10*(s[i]-'0')+s[i+1]-'0';
                            printf(
            "%c",str[num-1]);
                            i
            ++;
                            
            continue;
                        }
                        
            if(isdigit(s[i]) && !isdigit(s[i+1]))
                        {
                            num
            =s[i]-'0';
                            printf(
            "%c",str[num-1]);
                            
            continue;
                        }
                        
            if(s[i]=='#')   printf(" ");
                    }
                    printf(
            "\n");
                }
                
            return 0;
            }

            Feedback

            # re: HDOJ HDU 1982 Kaitou Kid - The Phantom Thief(1) ACM 1982 IN HDU   回復(fù)  更多評(píng)論   

            2010-09-19 09:06 by syx
            神牛這次和我離的不遠(yuǎn)了?。?/div>

            # re: HDOJ HDU 1982 Kaitou Kid - The Phantom Thief(1) ACM 1982 IN HDU [未登錄](méi)  回復(fù)  更多評(píng)論   

            2011-05-12 12:03 by star
            #include "stdio.h"
            int main()
            {
            int t,x;
            char c;
            scanf("%d",&t);
            getchar();
            while(t--)
            {
            x=0;
            c=getchar();
            while(c!='\n')
            {
            if(c>='0'&&c<='9')
            {x*=10;x+=c-'0';}
            else
            {
            if(x>=1&&x<=26)
            printf("%c",x+'A'-1);
            if(c=='#')
            printf(" ");
            x=0;
            }
            c=getchar();
            }
            if(x>=1&&x<=26)
            printf("%c",x+'A'-1);
            printf("\n");
            }
            }
            97久久超碰国产精品2021| 久久久噜噜噜久久| 久久国产热精品波多野结衣AV| 18岁日韩内射颜射午夜久久成人| 影音先锋女人AV鲁色资源网久久| 国产精品一区二区久久国产| 97久久国产亚洲精品超碰热| 久久男人中文字幕资源站| 久久强奷乱码老熟女网站| 国产精品久久久久天天影视| 99久久精品免费国产大片| 欧美精品丝袜久久久中文字幕 | 亚洲欧洲精品成人久久奇米网| 三级片免费观看久久| 亚洲午夜久久久久久噜噜噜| 久久久久国产精品| 无码精品久久一区二区三区| 久久久无码人妻精品无码| 狠狠色伊人久久精品综合网| 久久久噜噜噜久久中文字幕色伊伊 | 精品久久久无码人妻中文字幕| 精品一区二区久久| 久久只有这里有精品4| 久久成人精品视频| 中文精品99久久国产| 久久精品国产亚洲综合色| 久久99久久99精品免视看动漫| 国产成人综合久久精品尤物| 色综合久久中文字幕无码| 久久亚洲欧洲国产综合| 99久久中文字幕| 亚洲av伊人久久综合密臀性色| 久久嫩草影院免费看夜色| 国产精品久久久久影视不卡| 久久国语露脸国产精品电影| 久久免费视频6| 99久久亚洲综合精品网站| 久久久久亚洲Av无码专| 精品久久久无码21p发布| 人人狠狠综合久久亚洲高清| 99久久无码一区人妻|