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.


解题心得:

  1. 题意是问你第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的更多相关文章

  1. 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 ...

  2. Codeforces Round #460 (Div. 2)

    A. Supermarket We often go to supermarkets to buy some fruits or vegetables, and on the tag there pr ...

  3. [Codeforces]Codeforces Round #460 (Div. 2)

    Supermarket 找最便宜的就行 Solution Perfect Number 暴力做 Solution Seat Arrangement 注意当k=1时,横着和竖着是同一种方案 Soluti ...

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

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 直接暴力求出第k个perfect数字就好. 纯模拟. [代码] #include <bits/stdc++.h> #de ...

  5. 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 ...

  6. Codeforces Round #427 (Div. 2) B. The number on the board

    引子: A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会.... B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更 ...

  7. 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 ...

  8. Codeforces Round #460 (Div. 2) ABCDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8397685.html 2018-02-01 $A$ 题意概括 你要买$m$斤水果,现在有$n$个超市让你选择. ...

  9. 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 ...

随机推荐

  1. Centos 6.5 修改默认分辨率

    需要两步: 第一步: 编辑/etc/grub.conf文件,删除“nomodeset” 单词 ,翻到该页最后一行,就可以看到该词: 第二步: 删除文件/etc/X11/xorg.conf , Inte ...

  2. 前端三剑客之javascript

    前端三剑客之javascript 给个小目录  一.JavaScript介绍  二.ECMAScript(核心) 三.BOM对象(浏览器对象) 四.DOM对象(文档对象模型) 总结: JS的组成: a ...

  3. MATLAB之画确定区域内不重合的随机圆

    MATLAB之画确定区域内不重合的随机圆 程序要求:在确定区域内,画互不重合的圆. 知识点: (1)A=p'; 转置运算 (2)ones(a,b)产生a行b列全1数组 (3)rand(a,b)产生a行 ...

  4. @Enable*注解的工作原理

    @EnableAspectJAutoProxy @EnableAsync @EnableScheduling @EnableWebMv @EnableConfigurationProperties @ ...

  5. Cocos2d-x v3.1 坐标系统(五)

    Cocos2d-x v3.1 坐标系统(五) 为了能够更好的布局以及了解对象所在的位置,我们必须对Cocos2d-x中的坐标有详细的了解,本篇文章主要就是了解Cocos中用到的坐标系统.学过数学的人都 ...

  6. .net网站的下载地址

    .net4.0网址:http://www.crsky.com/soft/6959.htmlsql server r2: http://pan.baidu.com/share/link?shareid= ...

  7. 【SQL】连接 —— 内连接、外连接、左连接、右连接、交叉连接

    连接 · 内连接 · 外连接 · 左连接 · 右连接 · 全连接 · 交叉连接 · 匹配符号(+)  连接  根据表之间的关系,呈现跨表查询的结果.     外连接     内连接 左连接 右连接 全 ...

  8. Xcode Warning: “no rule to process file

    警告⚠️: warning: no rule to process file '/Users/Kingdev/Desktop/Git/finance_iOS/finance/Library/MBpro ...

  9. 【前端_js】解决ajax跨域请求数据

    1.ajax发送请求必须遵循同源策略,即请求方和相应方的协议头.域名.端口全部一样.只要三者有一个不一样都视为跨域,浏览器出于安全考虑不允许跨域访问. 解决ajax跨域访问的常用方法: a.使用jso ...

  10. linux主机状态检测方式

    之前写过一个简单的脚本检测当前网段中主机状态的脚本,内容如下: #! /bin/bash #ping check host status trap "exit" 2 sping() ...