Codeforces 919B. Perfect Number Solution
Solve in c++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd Batch
///Islamic University,Bangladesh
#include<iostream>
using namespace std;
main()
{
long long int n,r,i,s,a,b,c,j;
while(cin>>n)
{
c=0;
for(i=19;; i++)
{
j=i,s=0;
while(j>0)
{
s+=j%10;
j/=10;
}
if(s==10)
c++;
if(c==n)
break;
}
cout<<i<<endl;
}
}
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd Batch
///Islamic University,Bangladesh
#include<iostream>
using namespace std;
main()
{
long long int n,r,i,s,a,b,c,j;
while(cin>>n)
{
c=0;
for(i=19;; i++)
{
j=i,s=0;
while(j>0)
{
s+=j%10;
j/=10;
}
if(s==10)
c++;
if(c==n)
break;
}
cout<<i<<endl;
}
}
No comments