Codeforces 919 B. Perfect Number
2 seconds
256 megabytes
standard input
standard output
We 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.
A single line with a positive integer k (1 ≤ k ≤ 10 000).
A single number, denoting the k-th smallest perfect integer.
1
19
2
28
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 }
Codeforces 919 B. Perfect Number的更多相关文章
- Codeforces Round #460 (Div. 2)-B. Perfect Number
B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Descriptio ...
- Codeforces Round #460 (Div. 2) B Perfect Number(二分+数位dp)
题目传送门 B. Perfect Number time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- [codeforces 317]A. Perfect Pair
[codeforces 317]A. Perfect Pair 试题描述 Let us call a pair of integer numbers m-perfect, if at least on ...
- 507. Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- [LeetCode] Perfect Number 完美数字
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- [Swift]LeetCode507. 完美数 | Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...
- LeetCode算法题-Perfect Number(Java实现)
这是悦乐书的第249次更新,第262篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第116题(顺位题号是507).我们定义Perfect Number是一个正整数,它等于 ...
- Codeforces 980 D. Perfect Groups
\(>Codeforces\space980 D. Perfect Groups<\) 题目大意 : 设 \(F(S)\) 表示在集合\(S\)中把元素划分成若干组,使得每组内元素两两相乘 ...
- 507. Perfect Number 因数求和
[抄题]: We define the Perfect Number is a positive integer that is equal to the sum of all its positiv ...
随机推荐
- 动态设置html的title
使用vue前端框架做,竟然丢弃了很多javascript和html的东西了..动态设置title的方法: 1.使用vue的自定义指令 <div v-title>{{htmltitle}}& ...
- PHP将unicode转utf8最简法
最近开发时遇到Unicode编码问题,找了半天才知道PHP并没有Unicode转码函数,终于发现用一行PHP代码解决的方案: $str = '{"success":true,&qu ...
- OOP之单例模式
- 二叉排序树:POJ2418-Hardwood Species(外加字符串处理)
Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Description Hardwoods are the botanical gr ...
- ccna学习指南第七版
1.加电post自检 闪存查找ios 可随时从命令行进入设置模式,为此可在特权模式下输入setup ctrl+c退出特权模式 6.2cli 命令行界面 进入cli router> ...
- Leetcode 437.路径总和III
路径总和III 给定一个二叉树,它的每个结点都存放着一个整数值. 找出路径和等于给定数值的路径总数. 路径不需要从根节点开始,也不需要在叶子节点结束,但是路径方向必须是向下的(只能从父节点到子节点). ...
- 2017"百度之星"程序设计大赛 - 资格赛
度度熊与邪恶大魔王 Accepts: 3666 Submissions: 22474 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 集合篇 —— Collection(1):JDK 中的重复实现问题
1. 问题的提出 在 Java 的集合体系当中,无论是 List(列表)还是 Set(集),在设计的时候都存在一个很奇怪的现象:这两种集合的接口,Java 都为其设计了抽象类 Abstrac ...
- 一句话配置mongodb
一.安装mongodbmongodb-win32-x86_64-2008plus-ssl-3.2.9-signed.msi 二.以管理员身份,启动cmd命令mongod.exe --logpath & ...
- UVA11367 Full Tank? 【分层图最短路】
题目 After going through the receipts from your car trip through Europe this summer, you realised that ...