HDU 2096 小明A+B

來源:互聯網
上載者:User
小明A+B

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 20867    Accepted Submission(s): 9806


Problem Description小明今年3歲了, 現在他已經能夠認識100以內的非負整數, 並且能夠進行100以內的非負整數的加法計算.
對於大於等於100的整數, 小明僅保留該數的最後兩位進行計算, 如果計算結果大於等於100, 那麼小明也僅保留計算結果的最後兩位.

例如, 對於小明來說:
1) 1234和34是相等的
2) 35+80=15

給定非負整數A和B, 你的任務是代表小明計算出A+B的值. 


Input輸入資料的第一行為一個正整數T, 表示測試資料的組數. 然後是T組測試資料. 每組測試資料包含兩個非負整數A和B(A和B均在int型可表示的範圍內). 


Output對於每組測試資料, 輸出小明A+B的結果. 


Sample Input

235 8015 1152
 


Sample Output

1567
 

import java.io.*;import java.util.*;public class Main {Scanner sc;int a,b;public static void main(String[] args) {new Main().work();}void work(){sc=new Scanner(new BufferedInputStream(System.in));int t=sc.nextInt();while(t--!=0){int a=sc.nextInt();int b=sc.nextInt();if(a>=100){String s1=String.valueOf(a);a=Integer.parseInt(s1.substring(s1.length()-2));}if(b>=100){String s2=String.valueOf(b);b=Integer.parseInt(s2.substring(s2.length()-2));}int sum=a+b;if(sum>=100){String s=String.valueOf(sum);sum=Integer.parseInt(s.substring(s.length()-2));}System.out.println(sum);}}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.