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. IDEA生成增强for循环

    itar 生成array for代码块 for (int i = 0; i < array.length; i++) { = array[i]; } itco 生成Collection迭代 fo ...

  2. 第八节:pandas字符串

    Pandas提供了一组字符串函数,可以方便地对字符串数据进行操作.

  3. 内存_RAM或ROM_和FLASH存储的真正区别总结

    http://blog.sina.com.cn/s/blog_4b37304d0100fg10.html

  4. DSP28035的编程初步--GPIO操作

    明白DSP编程的基本流程,熟悉DSP28035的GPIO的使用.代码执行流程:首先是系统时钟的选择.其次是PIE中断向量表的初始化.一些外设的初始化操作While(){}根据EXPERIMENTER’ ...

  5. GlobalSign 增强型(EV) SSL 证书

    GlobalSign 增强型(EV) SSL 证书,属于最高验证级别的EV SSL,验证域名所有权,进行严格的企业真实身份验证,证书标识企业组织机构名称,强化信任度,浏览器地址栏变绿色.提供40位/5 ...

  6. [置顶] Git学习总结(1)——Git使用详细教程

    一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 二:SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以 ...

  7. xth的第 12 枚硬币(codevs 1366)

    题目描述 Description 传说 xth 曾经拥有11枚完全相同硬币(你懂得),不过今年呢,rabbit又送了他一 枚硬币.这枚硬币和其他硬币外观相同,只有重量不同,或轻或重.Xth 一不小心, ...

  8. shell面试题整理

    1.给一个放有IP的文件,其中一个IP一行,统计哪个IP出现的次数最多. ip_input.txt内容如下: 219.217.49.14 175.43.4.87 87.48.98.1 59.73.38 ...

  9. [bzoj3295][Cqoi2011]动态逆序对_主席树

    动态逆序对 bzoj-3295 Cqoi-2011 题目大意:题目链接. 注释:略. 想法:直接建立主席树. 由于是一个一个删除,所以我们先拿建立好的root[n]的权值线段树先把总逆序对求出来,接着 ...

  10. zookeeper协调技术

    本文转自http://www.cnblogs.com/wuxl360/p/5817471.html 感谢作者 一.分布式协调技术 在给大家介绍ZooKeeper之前先来给大家介绍一种技术——分布式协调 ...