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. Mysql 如何设置字段自动获取当前时间,附带添加字段和修改字段的例子

    --添加CreateTime 设置默认时间 CURRENT_TIMESTAMP  ALTER TABLE `table_name`ADD COLUMN  `CreateTime` datetime N ...

  2. Swift-字符串

    1.字符串的遍历 //NSString 不支持一下字符串的遍历 let str = "我要飞的更高" for c in str.characters{ print(c) } 2.字 ...

  3. poj3334(Connected Gheeves)

    Connected Gheeves Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1008   Accepted: 368 ...

  4. 用xaml画的带阴影3D感的圆球

    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"> <E ...

  5. OpenFirewall

    1.写一份json文件:将要添加防火墙例外的应用程序和端口写入到json文件中 2.打开防火墙,读取json文件添加例外 /// <summary> /// Firewall.xaml 的 ...

  6. VS找到了XXX的副本,但是当前源代码与XXX中内置的版本不同

    1.博客园有解决ASP.Net出现以上问题的方法: 删除ASP.Net临时文件夹内的dll文件. https://www.cnblogs.com/autumn/p/5261576.html 2.但我的 ...

  7. java Vamei快速教程07 包

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 我们已经写了一些Java程序.之前的每个Java程序都被保存为一个文件,比如Tes ...

  8. vuejs组件

    <div id='root'> <ul> <todo-item></todo-item> </ul> </div> <sc ...

  9. 输出流缓冲的意义 何时缓冲 Stdout Buffering

    From : https://eklitzke.org/stdout-buffering 译者:李秋豪 大多数编程语言默认提供了i/o缓冲特性,因为这会使得输出更加有效率.这些缓冲功能大都是默默工作& ...

  10. 设置meta标签 清除页面缓存,如:<meta http-equiv="Cache-Control" content="no-cache"/>

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" ...