反转相加。用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; }