• <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>
            posts - 21, comments - 2, trackbacks - 0, articles - 0

            ZOJ1292 , HDU 1047 Integer Inquiry

            Posted on 2011-09-05 23:22 acpeng 閱讀(774) 評論(0)  編輯 收藏 引用 所屬分類: ACM程序
            大數相加,字符模擬
            題目鏈接:
            ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1292
            HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1047

            Description
            One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.

            ``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)


            Input
            The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative).

            The final input line will contain a single zero on a line by itself.


            Output
            Your program should output the sum of the VeryLongIntegers given in the input.


            This problem contains multiple test cases!

            The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

            The output format consists of N output blocks. There is a blank line between output blocks.


            Sample Input

            1

            123456789012345678901234567890
            123456789012345678901234567890
            123456789012345678901234567890
            0


            Sample Output

            370370367037037036703703703670

            AC代碼:

            /*
            Accepted 1047 0MS 188K 1256 B C++ 
            */

            #include
            <stdio.h>
            #include
            <string.h>
            #define MaxSize 1000
            void FunBigAdd(char *str1,char *str2);
            int main()
            {
                
            char IntStr[MaxSize]="\0",str[MaxSize]="\0";
                
            int T,i;
                scanf(
            "%d",&T);
                
            while(T--)
                
            {
                    memset(str,
            0,MaxSize);
                    scanf(
            "%s",IntStr);
                    
            while(strcmp(IntStr,"0")!=0)
                    
            {
                        FunBigAdd(str,IntStr);
                        memset(IntStr,
            0,MaxSize);
                        scanf(
            "%s",IntStr);
                    }

                    i
            =0;
                    
            while(str[i]=='0' && str[i]!='\0')i++;
                    
            if(str[i]=='\0')printf("0\n");
                    
            else printf("%s\n",str+i);
                    
            if(T!=0)printf("\n");
                }

                
            return 0;
            }

            void strRevg(char *str)
            {
                
            int i;char temp;
                
            int lgth=(int)strlen(str)-1;
                
            for(i=0;i<lgth-i;i++)
                
            {
                    temp
            =*(str+i);
                    
            *(str+i)=*(str+lgth-i);
                    
            *(str+lgth-i)=temp;
                }

            }

            void FunBigAdd(char *str1,char *str2)
            {    
                
            int i=0,dec=0,tmp;
                strRevg(str1);
                strRevg(str2);
                
            while(*(str1+i)!='\0' || *(str2+i)!='\0')
                
            {
                    
            if(*(str1+i)=='\0')
                    
            {
                        
            *(str1+i)='0';
                        
            *(str1+i+1)='\0';
                    }

                    
            if(*(str2+i)=='\0')
                    
            {
                        
            *(str2+i)='0';
                        
            *(str2+i+1)='\0';
                    }

                    tmp
            =*(str1+i)-'0'+(*(str2+i)-'0')+dec;
                    
            *(str1+i)=tmp%10+'0';
                    dec
            =tmp/10;
                    i
            ++;
                }

                
            if(dec!=0*(str1+(i++))=dec+'0';
                
            *(str1+i)='\0';
                strRevg(str1);
            }



            国产精品99久久久久久宅男小说| 久久精品国产免费一区| 久久成人小视频| 久久Av无码精品人妻系列| 国产精品va久久久久久久| 久久国产AVJUST麻豆| 夜夜亚洲天天久久| 久久婷婷成人综合色综合| 欧美午夜精品久久久久久浪潮| 久久久久无码精品国产| 无码任你躁久久久久久| 国产精品亚洲美女久久久| 久久久无码精品亚洲日韩蜜臀浪潮 | 女人香蕉久久**毛片精品| 偷窥少妇久久久久久久久| 狠狠色丁香婷婷综合久久来来去| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 久久精品国产久精国产果冻传媒| 国产精品久久久久乳精品爆| 狠狠色丁香久久综合婷婷| 亚洲综合伊人久久大杳蕉| 国产精品久久久久久久久久影院| 久久成人精品| 久久久久亚洲AV无码专区桃色| 7777久久亚洲中文字幕| 久久人人妻人人爽人人爽| 久久香综合精品久久伊人| 日产精品久久久久久久| 2021国产精品午夜久久| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 狠狠久久综合伊人不卡| 亚洲国产精品一区二区久久| 国产91色综合久久免费| 国产精品福利一区二区久久| 国产午夜久久影院| 99久久国产主播综合精品| 久久精品国产72国产精福利| 久久青青草原精品国产不卡| 久久久久久久综合狠狠综合| 波多野结衣久久一区二区| 无码伊人66久久大杳蕉网站谷歌|