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 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.