`

HDU_2096_小明A+B

阅读更多
http://acm.hdu.edu.cn/showproblem.php?pid=2096

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
2
35 80
15 1152

Sample Output
15
67


#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <set>
//#include <map>
#include <queue>
#include <utility>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h>
using namespace std;

int main()
{
    int t, a, b;
    scanf ("%d", &t);
    while (t--)
    {
        scanf ("%d%d", &a, &b);
        a %= 100;
        b %= 100;    //第一次写的时候,错了一次,相加之前没有取余,发生中途溢出问题,无语
        a += b;
        a %= 100;
        printf ("%d\n", a);
    }
    return 0;
}
5
17
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics