zoukankan      html  css  js  c++  java
  • 每日一九度之 题目1089:数字反转

    时间限制:1 秒

    内存限制:32 兆

    特殊判题:

    提交:3452

    解决:1892

    题目描述:

        12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转。

    输入:

        第一行一个正整数表示测试数据的个数n。
        只有n行,每行两个正整数a和b(0<a,b<=10000)。

    输出:

        如果满足题目的要求输出a+b的值,否则输出NO。

    样例输入:
    2
    12 34
    99 1
    样例输出:
    46
    NO
    //Asimple
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <cctype>
    #include <cstdlib>
    #include <stack>
    #include <cmath>
    #include <set>
    #include <map>
    #include <string>
    #include <queue>
    #include <limits.h>
    #define INF 0x7fffffff
    #define mod 1000000000
    using namespace std;
    const int maxn = 10001;
    typedef long long ll;
    int n, x, y;
    
    int reverse(int n){//获取反转 
        int sum = 0;
        while( n ){
            sum *= 10;
            sum += n%10;
            n /= 10;
        }
        return sum;
    }
     
    int main(){
        cin >> n;
        while( n -- ){
            cin >> x >> y;
            if( reverse(x)+reverse(y) == reverse(x+y)){
                cout << x+y << endl;
            } else {
                cout << "NO" << endl;
            }
        }
        return 0;
    }
    低调做人,高调做事。
  • 相关阅读:
    NSLocalizedString用法
    4-27学习心得
    手势学习
    plist处理
    数据存储
    initWithFrame方法
    控制器跳转小常识
    UIGestureRecognizer学习笔记
    博客资源
    检测手机wifi有没有打开
  • 原文地址:https://www.cnblogs.com/Asimple/p/5990693.html
Copyright © 2011-2022 走看看