/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive / spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 1000010 bool status[MX]; int func(int n) { int nn=n; while(n) { nn+=n%10; n/=10; } return nn; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tc, kk=1, n; string s; char ch; for(int i=1;i<=1000000;i++) if(!status[i]) { cout<<i<<"\n"; for(int j=i;j<=1000000;) { j = func(j); if(status[j]) break; status[j]=true; } } return 0; }
Wednesday, 30 September 2015
UVA 640 Self Numbers (UVALive 5326, POJ 1316, HDU 1128, ZOJ 1180, SCU 2843, Regionals 1998 >> North America - Mid-Central USA)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment