Codeforces 919 B. Perfect Number
B. Perfect Number
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputWe consider a positive integer perfect, if and only if the sum of its digits is exactly 10. Given a positive integer k, your task is to find the k-th smallest perfect positive integer.
Input
A single line with a positive integer k (1 ≤ k ≤ 10 000).
Output
A single number, denoting the k-th smallest perfect integer.
Examples
input
1
output
19
input
2
output
28
Note
The first perfect integer is 19 and the second one is 28.
这个题想吐槽一下,我一开始写的多组输入,交上RE了,改了多组输入过了,本来以为自己多组输入初始化什么的写挫了,赛后改了改交上去还是RE,后来直接WA,放弃。多组输入不知道为什么错。。。
代码:
1 //B-这个题多组输入就不行。。。
2 #include<iostream>
3 #include<cstdio>
4 #include<algorithm>
5 #include<cstring>
6 #include<cstdlib>
7 #include<string.h>
8 #include<set>
9 #include<vector>
10 #include<queue>
11 #include<stack>
12 #include<map>
13 #include<cmath>
14 using namespace std;
15 int main(){
16 int n,cnt=0;
17 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
18 cin>>n;
19 for(int i=0;i<30000000;i++){
20 int temp=i;
21 int ans=0;
22 while(temp){
23 int x=temp%10;
24 ans+=x;
25 temp/=10;
26 }
27 if(ans==10)cnt++;
28 if(cnt==n){
29 cout<<i<<endl;
30 break;
31 }
32 }
33 }