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.

解题思路:题目的意思就是找出升序序列(每个数的每位数字总和都为10)中第k个数。暴力水过!

AC代码:

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k=,tmp,sum,obj[];bool flag;
for(int i=;k<;++i){
tmp=i;sum=;flag=false;
while(!flag && tmp){
if(sum>=)flag=true;//如果sum超过10就无需再比较下去了,因为此时的i一定不满足要求
sum+=tmp%;
tmp/=;
}
if(!flag && sum==)obj[k++]=i;
}
cin>>n;
cout<<obj[n-]<<endl;
return ;
}

E - Perfect Number的更多相关文章

  1. 507. Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  2. [LeetCode] Perfect Number 完美数字

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  3. [Swift]LeetCode507. 完美数 | Perfect Number

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  4. LeetCode算法题-Perfect Number(Java实现)

    这是悦乐书的第249次更新,第262篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第116题(顺位题号是507).我们定义Perfect Number是一个正整数,它等于 ...

  5. 507. Perfect Number 因数求和

    [抄题]: We define the Perfect Number is a positive integer that is equal to the sum of all its positiv ...

  6. LeetCode Perfect Number

    原题链接在这里:https://leetcode.com/problems/perfect-number/#/description 题目: We define the Perfect Number ...

  7. Codeforces Round #460 (Div. 2)-B. Perfect Number

    B. Perfect Number time limit per test2 seconds memory limit per test256 megabytes Problem Descriptio ...

  8. Codeforces 919 B. Perfect Number

      B. Perfect Number   time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  9. [LeetCode] 507. Perfect Number 完美数字

    We define the Perfect Number is a positive integer that is equal to the sum of all its positive divi ...

  10. 【leetcode】507. Perfect Number

    problem 507. Perfect Number solution: /* class Solution { public: bool checkPerfectNumber(int num) { ...

随机推荐

  1. img、a标签的使用

    <!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...

  2. 小白年薪26万,为什么Python岗位薪资越来越高?

    人工智能和大数据概念的兴起,带动了Python的快速增长——Python语言逻辑简洁.入门简单.生态丰富,几乎成为几个新兴领域的不二选择.而除了这两个领域,Python还有更多的适用领域:爬虫.web ...

  3. 创建pod索引库(Specs)

    专门用来存放xxx.podspec 的索引文件的库就叫做索引库.我们需要将这些索引文件上传到远程索引库才能保证其他的人能够拿来用. 创建一个远程索引库和本地索引库对应起来,步骤如下: 1.登录开源中国 ...

  4. NOIWC2019 冬眠记

    冬眠 由于THUWC考太差了没啥心情做事…… Day -1 报到日前一天晚上去看了看宿舍表,发现周围全是集训队,隔壁就是栋爷.高队和lca,再隔壁是zzq和wxh……吓傻了(本校buff这么好吗) D ...

  5. https://github.com/MediaTek-Labs/linkit-smart-7688-feed编译失败

    mkdir -p /home/fly/workdir/LinkltSmart7688Duo-20170626/openwrt/dl/home/fly/workdir/LinkltSmart7688Du ...

  6. bx值

    bx值 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem De ...

  7. MINSUB - Largest Submatrix

    MINSUB - Largest Submatrix no tags  You are given an matrix M (consisting of nonnegative integers) a ...

  8. springboot之多任务并行+线程池处理

    最近项目中做到一个关于批量发短信的业务,如果用户量特别大的话,不能使用单线程去发短信,只能尝试着使用多任务来完成!我们的项目使用到了方式二,即Future的方案 Java 线程池 Java通过Exec ...

  9. JAVA大数据项目+整理的Mysql数据库32条军规

    http://www.jianshu.com/users/a9b2d43bb94e/latest_articles

  10. Android測试环境变量配置表

    要改动的文件是~/bash_profile这个配置文件,内容例如以下: # Setting PATH for Java JAVA_HOME="/Library/Java/JavaVirtua ...