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 ...
随机推荐
- 流程控制之while循环for循环
流程控制之while循环1.什么是循环 循环就是重复做某件事2.为什么要有循环 为了让计算机能够具备人重复做某件事的能力3.如何用循环 while语法: while 条件: code1 code2 c ...
- Python语言的简介
___________________________________________________________我是一条分割线__________________________________ ...
- java/jsp执行sql语句的方式
首先给出sql驱动包 引入sql包 import java.sql.*;//java <%@ page import="java.sql.*"%>//jsp 连接mys ...
- poj 1321 排兵布阵问题 dfs算法
题意:有不规则地图,在上面放n个相同的棋子,要求摆放的时候不同行不同列.问:有多少种摆法? 思路:dfs+回溯 用一个book[]数组来表示当前列是否有放棋子 一行一行的遍历,对一行来说遍历它的列,如 ...
- Monkeyrunner 简介及其环境搭建
Monkeyrunner是通过坐标.控件ID和控件上的文字操作应用的界面元素,其测试用例是用python写的,这样就弥补了monkey只有简单命令无法执行复杂用例的缺陷.Monkeyrunner采用的 ...
- AngularJS自定义指令directive:scope属性 (转载)
原文地址:http://blog.csdn.net/VitaLemon__/article/details/52213103 一.介绍: 在AngularJS中,除了内置指令如ng-click等,我们 ...
- leetcode with python -> tree
100. Same Tree Given two binary trees, write a function to check if they are the same or not. Two bi ...
- Spider爬虫-get、post请求
1:概念: 爬虫就是通过编写程序,模拟浏览器上网,然后让其去互联网上抓取数据的过程. 2:python爬虫与其他语言的比较: (1)php爬虫弊端:多进程多线程支持的不好 (2)java:代码臃肿,重 ...
- ABP数据库的迁移
添加表,一(Test)对多(Test1)关系 Test using Abp.Domain.Entities.Auditing; using System; using System.Collectio ...
- iOS学习笔记26-视频播放
一.视频 在iOS中播放视频可以使用两个框架来实现: MediaPlayer框架的MPMoviePlayerController和MPMoviePlayerViewController AVFound ...