#include <iostream>
#include <cmath>
using namespace std;
long long Reverse(long long num)
{
long long dig,len = log10(num) , val = num;
long long renum = 0;
while (num)
{
dig = num%10;
long long ji = 1;
for (int i = 0 ; i != len ; ++i) //????????pow()????????????????????????
ji *= 10;
renum += dig*ji;
num /= 10;
len--;
}
return renum;
}
int main()
{
long long num,cnt = 0;
cin >> num;
bool flag = false;
while (log10(num)<=15){
if (num == Reverse(num)){
flag = true;
break;
}
else {
num += Reverse(num);
cnt++;
}
}
if (flag) cout << cnt;
else cout << "Fail!";
}
【基础试题】回文数弱版 Time Limit:10000MS Memory Limit:65536K Total Submit:271 Accepted:87 Case Time Limit:1
最新推荐文章于 2021-11-25 15:27:38 发布