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. linu下nginx的安装

    这里用到的环境是nginx-1.8.0,linux用的是CentOS-7-x86_64-DVD-1804.iso版本 1   什么是nginx Nginx ("engine x") ...

  2. Ubuntu 18.04 nvidia driver 390.48 安装 TensorFlow 1.12.0 和 PyTorch 1.0.0 详细教程

    最近要在个人台式机上搭建TensorFlow和PyTorch运行环境,期间遇到了一些问题.这里就把解决的过程记录下来,同时也可以作为安装上述环境的过程记录. 如果没有遇到类似的问题,想直接从零安装上述 ...

  3. BZOJ 2501 [usaco2010 Oct]Soda Machine

    [题意概述] 给出一个[0,1,000,000,000]的整数数轴,刚开始每个位置都为0,有n个区间加操作,最后询问数轴上最大的数是多少. [题解] 我写的是离散化后线段树维护区间最值. 其实貌似不用 ...

  4. SCI 计算机 数学相关期刊

    数学,电子通信,计算机类 出版地 收录库 刊名 刊期 ISSN 影响因子 中国大陆 SCI CHINESE SCIENCE BULLETIN<科学通报>(英文版) 半月刊 1001-653 ...

  5. 【hiho一下 第146周】子矩阵求和

    [题目链接]:http://hihocoder.com/contest/hiho146/problem/1 [题意] [题解] 设s[i][j]表示左上角的坐标为(i,j)的n*m的矩阵的和; 有s[ ...

  6. 创建RpcEnv

    感觉这篇文章不错 2.1.2.创建RpcEnv -  RpcEndpoint -  RpcEndpointRef val systemName = if (isDriver) driverSystem ...

  7. [cogs736][网络流24题#13]星际转移[网络流,网络判定]

    将一个空间站分为天数个点,每次枚举天数,每增加一天就把对应天数的边连上,用网络流判定可行性,即-判断最大流是否不小于k,注意编号不要错位.通过此题,可见一些网络流题目需要用到网络判定方法,但虽然答案具 ...

  8. getAttribute for IE7

    getAttribute 大部分介绍都说仅仅有一个.包含w3cschool. 事实上这种方法在iE7下有两个參数. msdn 上查到的. 简单翻一下 0 是默认情况,不区分大写和小写! 1 区分大写和 ...

  9. 专业函数画图软件Origin

    首先:Origin软件已经是科研院所等单位的必备工作软件之中的一个,之所以大家讨论得较少,有可能并非其上手难度低.而是这些使用人群的学习理解能力要相对高一点吧: 其次:Excel不垃圾,但在函数画图方 ...

  10. HDU 5289 Assignment (ST算法区间最值+二分)

    题目链接:pid=5289">http://acm.hdu.edu.cn/showproblem.php?pid=5289 题面: Assignment Time Limit: 400 ...