• <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 閱讀(775) 評(píng)論(0)  編輯 收藏 引用 所屬分類: ACM程序
            大數(shù)相加,字符模擬
            題目鏈接:
            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);
            }



            精品久久久噜噜噜久久久| 一本大道久久香蕉成人网| 97久久精品人妻人人搡人人玩| 婷婷国产天堂久久综合五月| 久久精品国产乱子伦| 国内精品久久久久久99蜜桃 | 久久午夜无码鲁丝片| 久久久久亚洲av无码专区喷水| 午夜不卡久久精品无码免费| 曰曰摸天天摸人人看久久久| 久久99精品久久久大学生| 久久国产精品无码HDAV| 伊人色综合久久天天网| 亚洲国产精品婷婷久久| 无码人妻精品一区二区三区久久| 久久久国产精华液| 97久久超碰成人精品网站| 国产精品一区二区久久精品涩爱| 青青草国产精品久久久久| 精品人妻伦九区久久AAA片69| 久久综合九色综合欧美狠狠| 国内高清久久久久久| 人人狠狠综合久久亚洲高清| 国产激情久久久久影院小草 | 久久www免费人成精品香蕉| 久久婷婷五月综合97色直播| 久久香蕉国产线看观看猫咪?v| 久久综合狠狠综合久久激情 | 日日噜噜夜夜狠狠久久丁香五月| 四虎亚洲国产成人久久精品| 日本免费久久久久久久网站| 无码超乳爆乳中文字幕久久| 亚洲香蕉网久久综合影视| 亚洲人成伊人成综合网久久久| 久久亚洲精品无码AV红樱桃| 久久精品国产男包| 久久精品亚洲一区二区三区浴池| 人人狠狠综合久久88成人| 国产三级久久久精品麻豆三级| 亚洲va久久久噜噜噜久久| 久久精品人人槡人妻人人玩AV|