【Codeforces Round #460 (Div. 2) B】 Perfect Number

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

直接暴力求出第k个perfect数字就好。 纯模拟。

【代码】

#include <bits/stdc++.h>
#define double long double
using namespace std;

int n;

int _judge(int x){
    int num = 0;
    while (x){
        num+=x%10;
        x/=10;
    }
    return num==10;
}

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    int k = 0;
    for (int i = 1;i <= (int)2e7;i++)
        if (_judge(i)){
            k++;
            if (k==n){
                cout<<i<<endl;
                break;
            }
        }
	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/8396435.html