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;
    }

}


No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.