http://codeforces.com/contest/876/problem/C

C. Classroom Watch
time limit per test

1 second

memory limit per test

512 megabytes

input

standard input

output

standard output

Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n. He asked what is this number and the teacher of mathematics Inna Petrovna answered Vova that n is the answer to the arithmetic task for first-graders. In the textbook, a certain positive integer x was given. The task was to add x to the sum of the digits of the number xwritten in decimal numeral system.

Since the number n on the board was small, Vova quickly guessed which x could be in the textbook. Now he wants to get a program which will search for arbitrary values of the number n for all suitable values of x or determine that such x does not exist. Write such a program for Vova.

Input

The first line contains integer n (1 ≤ n ≤ 109).

Output

In the first line print one integer k — number of different values of x satisfying the condition.

In next k lines print these values in ascending order.

Examples
input
21
output
1
15
input
20
output
0
Note

In the first test case x = 15 there is only one variant: 15 + 1 + 5 = 21.

In the second test case there are no such x.

题意:

找出所有的x,满足x+x的每一位=n

因为n<=1e9,所以最大的数位之和为81

从n-81 开始枚举即可

#include<cstdio>
#include<algorithm> using namespace std; int n,tot,ans[]; bool check(int x)
{
int y=x,cnt=x;
while(y) cnt+=y%,y/=;
return cnt==n;
} int main()
{
scanf("%d",&n);
for(int i=max(,n-);i<=n;i++)
if(check(i)) ans[++tot]=i;
printf("%d\n",tot);
for(int i=;i<=tot;i++) printf("%d ",ans[i]);
}

codeforces 876 C. Classroom Watch的更多相关文章

  1. codeforces 876 D. Sorting the Coins

    http://codeforces.com/contest/876/problem/D D. Sorting the Coins time limit per test 1 second memory ...

  2. codeforces 876 F. High Cry(思维)

    题目链接:http://codeforces.com/contest/876/problem/F 题解:一道简单的思维题,知道最多一共有n*(n+1)/2种组合,不用直接找答案直接用总的组合数减去不符 ...

  3. codeforces 876 D. Sorting the Coins(线段树(不用线段树写也行线段树写比较装逼))

    题目链接:http://codeforces.com/contest/876/problem/D 题解:一道简单的类似模拟的题目.其实就是看右边连出来有多少连续不需要换的假设位置为pos只要找pos- ...

  4. Codeforces 1166A - Silent Classroom

    题目链接:http://codeforces.com/problemset/problem/1166/A 思路:统计所有首字母出现的次数,由贪心可知对半分最少. AC代码: #include<i ...

  5. [Codeforces 876]比赛记录

    上场$rating$果然炸飞,但是据说这次只要不$FST$就能翻回来QWQ? T1  $dfs$乱搞? T2  取模乱搞,$STL$ $vector$大法好(%%%$ryf$秒出做法) T3  看了半 ...

  6. Codeforces Round #441 (Div. 2)【A、B、C、D】

    Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...

  7. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) C. Classroom Watch

    http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: ...

  8. Codeforces 876C Classroom Watch:枚举

    题目链接:http://codeforces.com/contest/876/problem/C 题意: 定义函数:f(x) = x + 十进制下x各位上的数字之和 给你f(x)的值(f(x) < ...

  9. Codeforces Round #561 (Div. 2) A. Silent Classroom

    链接:https://codeforces.com/contest/1166/problem/A 题意: There are nn students in the first grade of Nlo ...

随机推荐

  1. Thunder团队——bug修正

    团队:欢迎来怼 发现的问题: 1.首先用户通过爱阅APP内部的网址跳转到各大电子书网站时,需要额外启动手机自身浏览器:就以豆瓣网为例,阅读豆瓣网上的一些书籍,是跳转到手机自带浏览器的,APP内部提供的 ...

  2. HDU 5170 GTY's math problem 水题

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5170 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

  3. net项目调试时,读取主干或其他项目代码问题

    最近调试项目的时候出了一个很奇怪的问题. 项目总是去读取另外一个项目的配置文件,甚至执行的代码都是另外一个项目的. 我用vs修改代码时候,甚至修改到了其他项目的代码,生成不报错,很奇怪. 本来怀疑是v ...

  4. JAVA之路(一)

    距离做下复习JAVA并学好JAVA的决定已经过去一周了,我买了慕课网的JAVA入门视频,在图书馆借了三本关于JAVA的书——两本是JAVA入门经典,一本是JAVA WEB开发宝典.我的计划是短时间内复 ...

  5. 使用Logstash同步数据至Elasticsearch,Spring Boot中集成Elasticsearch实现搜索

    安装logstash.同步数据至ElasticSearch 为什么使用logstash来同步,CSDN上有一篇文章简要的分析了以下几种同步工具的优缺点:https://blog.csdn.net/la ...

  6. 解决zabbix使用中文是出现乱码的问题

       解决zabbix使用中文是出现乱码的问题 ①:上传windows的simhei.ttf字体到zabbix服务器的/usr/share/zabbix/fonts/目录下   ②:编辑/usr/sh ...

  7. MySQL 基于lvm2的备份实战演练 (快照备份)

    前言: lvm2实现热备的原理是基于lvm2的快照功能,lvm2可以实现数据集不大的情况下的热备. 实战过程如下:这里的演示是在一台Mariadb服务器上进行创建快照,将快照中的文件scp到备份服务器 ...

  8. 查询出menupath字段中 出现 “- "(横杆)大于3次的 记录

  9. linux 上传下载

    xshell yum就是傻瓜式的安装软件,你要装什么,yum什么就行了,红帽系统才有yum,乌班图和debian是没有的 输入命令:sudo yum -y install lrzsz rz  上传 从 ...

  10. 转---秒杀多线程第十二篇 多线程同步内功心法——PV操作上 (续)

    PV操作的核心就是 PV操作可以同时起到同步与互斥的作用. 1.同步就是通过P操作获取信号量,V操作释放信号量来进行. 2.互斥其实就是,同时操作P操作,结束后进行V操作即可做到. Java上实现PV ...