1 solutions
-
0
C :
#include<stdio.h> void main(){ int n,t,x,c=0; scanf("%d",&n); while(1==1){ t=n; x=0; while(t!=0){ x=x*10+t%10; t=t/10; } if(n==x){ break; }else{ n=n+x; c++; } } printf("%d",c); }
C++ :
#include<iostream> using namespace std; int main(){ int n,i,j,t,d,m; cin>>n; for(i=1;;i++){ d=n; m=0; for(j=1;;j++){ if(n==0){ break; } t=n%10; m=m*10+t; n=n/10; } if(m==d){ cout<<i-1; break; }else{ n=d+m; } } }
Python :
n = int(input()) t = 0 while(n != int(str(n)[::-1])): n += int(str(n)[::-1]) t += 1 print(t)
- 1
Information
- ID
- 10807
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By