现在的位置: 首页 > 综合 > 正文

UVA10018

2018年04月21日 ⁄ 综合 ⁄ 共 429字 ⁄ 字号 评论关闭

反转相加。用sscanf sprintf CE了。。然后就换方法了。。。个人觉得就是个模拟的过程。。

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
LL Rev(LL a){
    LL x = 0,y = 0;
    while(a > 0){
        x = a % 10;
        y = y * 10 + x;
        a /= 10;
    }
    return y;
}
bool Judge(LL a,LL b){
    if(a == b) return true;
    return false;
}
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        LL a,b;
        cin>>a;
        b = Rev(a);
        int count = 0;
        while(1){
            if(Judge(a,b)) break;
            a += b;
            b = Rev(a);
            count++;
        }
        cout<<count<<" "<<b<<endl;
    }
    return 0;
}

【上篇】
【下篇】

抱歉!评论已关闭.