Codeforces Round #460 (Div. 2)-B. Perfect Number
B. Perfect Number
time limit per test2 seconds
memory limit per test256 megabytes
Problem Description
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.
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.
解题心得:
- 题意是问你第n个所有位数之和加在一起为10的数是多少,刚开始也不知道数据范围,写了一个暴力程序跑了一下极限数据,极限数据也就1e7 多一点,时间给了2s,暴力轻松过。
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e4+100;
long long num[maxn],tot = 0;
long long get_sum(int x)
{
int sum = 0;
while(x)
{
int temp = x%10;
sum += temp;
x /= 10;
}
return sum;
}
int main()
{
int n;
scanf("%d",&n);
for(long long i=19;;i++)
{
long long sum = get_sum(i);
if(sum == 10)
{
tot++;
if(tot == n)
{
printf("%lld",i);
break;
}
}
}
return 0;
}
Codeforces Round #460 (Div. 2)-B. Perfect Number的更多相关文章
- 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 Round #460 (Div. 2)
A. Supermarket We often go to supermarkets to buy some fruits or vegetables, and on the tag there pr ...
- [Codeforces]Codeforces Round #460 (Div. 2)
Supermarket 找最便宜的就行 Solution Perfect Number 暴力做 Solution Seat Arrangement 注意当k=1时,横着和竖着是同一种方案 Soluti ...
- 【Codeforces Round #460 (Div. 2) B】 Perfect Number
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 直接暴力求出第k个perfect数字就好. 纯模拟. [代码] #include <bits/stdc++.h> #de ...
- Codeforces Round #188 (Div. 2) C. Perfect Pair 数学
B. Strings of Power Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/p ...
- Codeforces Round #427 (Div. 2) B. The number on the board
引子: A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会.... B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更 ...
- Codeforces Round #585 (Div. 2) B. The Number of Products(DP)
链接: https://codeforces.com/contest/1215/problem/B 题意: You are given a sequence a1,a2,-,an consisting ...
- Codeforces Round #460 (Div. 2) ABCDE题解
原文链接http://www.cnblogs.com/zhouzhendong/p/8397685.html 2018-02-01 $A$ 题意概括 你要买$m$斤水果,现在有$n$个超市让你选择. ...
- Codeforces Round #411 div 2 D. Minimum number of steps
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...
随机推荐
- Spring AOP的增强处理
就是@Before @Around @AfterReturning @AfterThrowing这几个标签的属性可以放到方法参数里面获取 例子 //正常操作@Around("service( ...
- jQuery 方法 属性
Attribute:$("p").addClass(css中定义的样式类型); 给某个元素添加样式$("img").attr({src:"test.j ...
- P1868 饥饿的奶牛
题目描述 有一条奶牛冲出了围栏,来到了一处圣地(对于奶牛来说),上面用牛语写着一段文字. 现用汉语翻译为: 有N个区间,每个区间x,y表示提供的x~y共y-x+1堆优质牧草.你可以选择任意区间但不能有 ...
- 线程池模块thernd
from concurrent.futures import ThreadPoolExecutor,ProcessPoolExecutor import time def task(i): print ...
- 在MVC中加载view(点开链接)的方式
主要有: Html.ActionLink Html.RenderPartial Html.RenderAction Html.Partial AJAX.ActionLink load 浏览器对象模型 ...
- 【Orange Pi Lite2】 ——2《在使用之前的配置》(未完)
[Orange Pi Lite2] --2<在使用之前的配置> 本文只在博客园发布 在开始前你需要准备的材料与软件 filezilla/或者不 声明 : 本教程适合0基础新手,本章将会介绍 ...
- Extjs4.1+desktop+SSH2 搭建环境 项目能跑起来
linux开发感觉可能就是日常办公的时候,用别的软件会有问题,java开发还是没什么区别的,换回window开发: push 它: 每次看到右上那红红的叉,我还以为又出错了: 这个项目用resin,下 ...
- 【BZOJ2427】[HAOI2010] 软件安装(缩点+树形DP)
点此看题面 大致题意: 有\(N\)个软件,每个软件有至多一个依赖以及一个所占空间大小\(W_i\),只有当一个软件的直接依赖和所有的间接依赖都安装了,它才能正常工作并造成\(V_i\)的价值.求在容 ...
- Softmax回归(Softmax Regression
多分类问题 在一个多分类问题中,因变量y有k个取值,即.例如在邮件分类问题中,我们要把邮件分为垃圾邮件.个人邮件.工作邮件3类,目标值y是一个有3个取值的离散值.这是一个多分类问题,二分类模型在这里不 ...
- AngularJs学习笔记-表单处理
表单处理 (1)Angular表单API 1.模板式表单,需引入FormsModule 2.响应式表单,需引入ReactiveFormsModule (2)模板式表单 在Angular中使用for ...