标签:lse col std int turn namespace als IV color
#include<bits/stdc++.h> using namespace std; long long p[20]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000,1000000000000}; bool judge(long long x){ int l=(int)(log10(x)+1); for(int i=1;i<=l/2;i++){ if((x%p[i])/p[i-1]!=(x%p[l-i+1])/p[l-i])return false; } return true; } long long reverse(long long x){ int l=(int)(log10(x)+1); long long res=0; int u; for(int i=0;i<l;i++){ u=x%10; x/=10; res+=u*p[l-i-1]; } return res; } int main(){ long long n; scanf("%lld",&n); int cnt=0; do{ cnt+=1; n=n+reverse(n); if(judge(n)){ printf("%d %lld",cnt,n); break; } }while(1); }
标签:lse col std int turn namespace als IV color
原文地址:https://www.cnblogs.com/TAMING/p/9096796.html