• <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>

            coreBugZJ

            此 blog 已棄。

            Adding Reversed Numbers,spoj 42

            42. Adding Reversed Numbers

            Problem code: ADDREV

            The Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Therefore the dramatic advisor of ACM has decided to transfigure some tragedies into comedies. Obviously, this work is very hard because the basic sense of the play must be kept intact, although all the things change to their opposites. For example the numbers: if any number appears in the tragedy, it must be converted to its reversed form before being accepted into the comedy play.

            Reversed number is a number written in arabic numerals but the order of digits is reversed. The first digit becomes last and vice versa. For example, if the main hero had 1245 strawberries in the tragedy, he has 5421 of them now. Note that all the leading zeros are omitted. That means if the number ends with a zero, the zero is lost by reversing (e.g. 1200 gives 21). Also note that the reversed number never has any trailing zeros.

            ACM needs to calculate with reversed numbers. Your task is to add two reversed numbers and output their reversed sum. Of course, the result is not unique because any particular number is a reversed form of several numbers (e.g. 21 could be 12, 120 or 1200 before reversing). Thus we must assume that no zeros were lost by reversing (e.g. assume that the original number was 12).

            Input

            The input consists of N cases (equal to about 10000). The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly one line with two positive integers separated by space. These are the reversed numbers you are to add.

            Output

            For each case, print exactly one line containing only one integer - the reversed sum of two reversed numbers. Omit any leading zeros in the output.

            Example

            Sample input: 

            3
            24 1
            4358 754
            305 794

            Sample output:

            34
            1998
            1


            一段時間沒寫匯編了,使用輸入緩沖提高效率。。。


              1 ; spoj42.s
              2 
              3 %define  L  1024
              4 
              5 section .bss
              6         pBuf  : resb  L
              7         pBufN : resd 1
              8         pBufI : resd 1
              9 
             10 section .text
             11         global _start
             12 
             13 _start : 
             14         mov dword[pBufN], 0x0
             15         mov dword[pBufI], 0x0
             16         call inInt
             17 CASE : 
             18         test eax, eax
             19         jz EXIT
             20         dec eax
             21         push eax
             22 
             23         call inIntR
             24         push eax
             25         call inIntR
             26         pop ebx
             27         add eax, ebx
             28         call outIntLnR
             29 
             30         pop eax
             31         jmp CASE
             32 EXIT : 
             33         mov eax, 0x1
             34         mov ebx, 0x0
             35         int 0x80
             36 
             37 in eax
             38 inChar : 
             39         mov eax, [pBufI]
             40         mov ebx, [pBufN]
             41         cmp eax, ebx
             42         jne NOEMPTY
             43         mov eax, 0x3
             44         mov ebx, 0
             45         mov ecx, pBuf
             46         mov edx, L
             47         int 0x80
             48         mov [pBufN], eax
             49         mov dword[pBufI], 0
             50         xor eax, eax
             51 NOEMPTY : 
             52         mov ebx, eax
             53         inc ebx
             54         mov [pBufI], ebx
             55         add eax, pBuf
             56         mov bl, byte[eax]
             57         xor eax, eax
             58         mov al, bl
             59         ret
             60 
             61 in eax
             62 inInt : 
             63         xor eax, eax
             64         push eax
             65 SKIPSPACE : 
             66         call inChar
             67         cmp al, '0'
             68         jb SKIPSPACE
             69         cmp al, '9'
             70         ja SKIPSPACE
             71 INDIGIT : 
             72         mov ebx, eax
             73         pop eax
             74         mov ecx, 0xA
             75         xor edx, edx
             76         mul ecx
             77         sub ebx, '0'
             78         add eax, ebx
             79         push eax
             80 
             81         call inChar
             82         cmp al, '0'
             83         jb INDIGITEND
             84         cmp al, '9'
             85         ja INDIGITEND
             86         jmp INDIGIT
             87 INDIGITEND : 
             88         pop eax
             89         ret
             90 
             91 in eax
             92 inIntR : 
             93         xor eax, eax
             94         push eax
             95         mov eax, 0x1
             96         push eax
             97 SKIPSPACER : 
             98         call inChar
             99         cmp al, '0'
            100         jb SKIPSPACER
            101         cmp al, '9'
            102         ja SKIPSPACER
            103 INDIGITR : 
            104         sub eax, '0'
            105         pop ebx
            106         xor edx, edx
            107         mul ebx
            108         pop ecx
            109         add eax, ecx
            110         push eax
            111         mov eax, ebx
            112         mov ecx, 0xA
            113         xor edx, edx
            114         mul ecx
            115         push eax
            116         
            117         call inChar
            118         cmp al, '0'
            119         jb inIntRend
            120         cmp al, '9'
            121         ja inIntRend
            122         jmp INDIGITR
            123 inIntRend : 
            124         pop eax
            125         pop eax
            126         ret
            127 
            128 out eax
            129 outIntLnR : 
            130         push ebp
            131         mov ebp, esp
            132         sub esp, 100
            133         mov ebx, esp
            134 ZEROBEG : 
            135         test eax, eax
            136         jz ZEROEND
            137         mov ecx, 0xA
            138         xor edx, edx
            139         div ecx
            140         add edx, '0'
            141         mov byte[ebx], dl
            142         inc ebx
            143         jmp ZEROBEG
            144 ZEROEND : 
            145         mov eax, esp
            146 ZEROSKIP : 
            147         mov cl, byte[eax]
            148         cmp cl, '0'
            149         jnz ZEROSKIPEND
            150         inc eax
            151         jmp ZEROSKIP
            152 ZEROSKIPEND : 
            153         mov byte[ebx], 0xA
            154         inc ebx
            155         mov edx, ebx
            156         sub edx, eax
            157         mov ecx, eax
            158         mov eax, 0x4
            159         mov ebx, 0x1
            160         int 0x80
            161 
            162         mov esp, ebp
            163         pop ebp
            164         ret
            165 

            posted on 2011-05-18 15:27 coreBugZJ 閱讀(724) 評論(0)  編輯 收藏 引用 所屬分類: Assemble

            国产高潮久久免费观看| 亚洲日本久久久午夜精品| 亚洲精品无码久久久影院相关影片| 波多野结衣久久精品| 无码日韩人妻精品久久蜜桃| 国产成人综合久久精品尤物| 亚洲&#228;v永久无码精品天堂久久 | 99久久国产综合精品网成人影院| 久久久久亚洲AV成人网人人网站| 久久人妻少妇嫩草AV无码专区| 久久久久一区二区三区| 伊人色综合久久天天网| 久久电影网2021| 久久精品日日躁夜夜躁欧美| 久久亚洲欧美日本精品| 亚洲va久久久噜噜噜久久 | 久久涩综合| 99久久免费只有精品国产| 无码精品久久久天天影视| 久久精品国产第一区二区| 久久精品国产影库免费看| 日本久久久久亚洲中字幕| 久久亚洲国产最新网站| 精品熟女少妇aⅴ免费久久| 久久精品一区二区国产| 婷婷综合久久中文字幕蜜桃三电影| 久久午夜福利电影| 久久人人爽人人爽人人片AV麻豆| 国产成人综合久久精品尤物| 国产精品99精品久久免费| 日产精品99久久久久久| 日本强好片久久久久久AAA| 精品久久久久久国产| 亚洲国产精品无码久久| 97精品伊人久久久大香线蕉| 人妻无码αv中文字幕久久琪琪布 人妻无码精品久久亚瑟影视 | 欧美午夜A∨大片久久 | 精品欧美一区二区三区久久久| 久久精品国产精品亚洲精品| 国产精品久久午夜夜伦鲁鲁| 国内精品九九久久久精品|