Discription

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 x written 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.

Example

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.

很显然每位数的和的贡献不可能太大,对于题目的范围来说肯定是<100的,所以枚举比n小100之内的数就行了。。

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int num[1005];
int n,m,k; inline int get(int x){
int an=0,nxt;
while(x){
nxt=x/10;
an+=x-nxt*10;
x=nxt;
}
return an;
} int main(){
cin>>n;
k=max(1,n-100);
for(int i=k;i<n;i++) if(i==n-get(i)) num[++m]=i; printf("%d\n",m);
for(int i=1;i<=m;i++) printf("%d\n",num[i]);
return 0;
}

  

「Codeforces Round #441」 Classroom Watch的更多相关文章

  1. 【LOJ #6094. 「Codeforces Round #418」归乡迷途】

    题目大意: 传送门. lca说的很明白就不重复了. 题解: 先膜一发lca. 大体读完题以后我们可以知道对于第i个节点最短路一定是连向1到i-1中的某个点. 然后我们考虑将到1距离(这里及以下均是最短 ...

  2. codeforces Round #441 C Classroom Watch【枚举/注意起点】

    C. time limit per test 1 second memory limit per test 512 megabytes input standard input output stan ...

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

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

  4. Codeforces Round #441 (Div. 2)

    Codeforces Round #441 (Div. 2) A. Trip For Meal 题目描述:给出\(3\)个点,以及任意两个点之间的距离,求从\(1\)个点出发,再走\(n-1\)个点的 ...

  5. loj #547. 「LibreOJ β Round #7」匹配字符串

    #547. 「LibreOJ β Round #7」匹配字符串   题目描述 对于一个 01 串(即由字符 0 和 1 组成的字符串)sss,我们称 sss 合法,当且仅当串 sss 的任意一个长度为 ...

  6. [LOJ#531]「LibreOJ β Round #5」游戏

    [LOJ#531]「LibreOJ β Round #5」游戏 试题描述 LCR 三分钟就解决了问题,她自信地输入了结果-- > -- 正在检查程序 -- > -- 检查通过,正在评估智商 ...

  7. [LOJ#530]「LibreOJ β Round #5」最小倍数

    [LOJ#530]「LibreOJ β Round #5」最小倍数 试题描述 第二天,LCR 终于启动了备份存储器,准备上传数据时,却没有找到熟悉的文件资源,取而代之的是而屏幕上显示的一段话: 您的文 ...

  8. [LOJ#516]「LibreOJ β Round #2」DP 一般看规律

    [LOJ#516]「LibreOJ β Round #2」DP 一般看规律 试题描述 给定一个长度为 \(n\) 的序列 \(a\),一共有 \(m\) 个操作. 每次操作的内容为:给定 \(x,y\ ...

  9. [LOJ#515]「LibreOJ β Round #2」贪心只能过样例

    [LOJ#515]「LibreOJ β Round #2」贪心只能过样例 试题描述 一共有 \(n\) 个数,第 \(i\) 个数 \(x_i\) 可以取 \([a_i , b_i]\) 中任意值. ...

随机推荐

  1. Heat 如何来实现和支持编排

    编排 编排,顾名思义,就是按照一定的目的依次排列.在 IT 的世界里头,一个完整的编排一般包括设置服务器上机器.安装 CPU.内存.硬盘.通电.插入网络接口.安装操作系统.配置操作系统.安装中间件.配 ...

  2. 【志银】NYOJ《题目524》A-B Problem

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 My思路: 先用两个字符串储存这两个实数,然后再用另外两个字符串储存去掉符号和前后多 ...

  3. ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

    这是在python中使用caffe产生的错误. 程序很普通: #-*-coding=utf-8-*- import numpy as npimport matplotlib.pyplot as plt ...

  4. HDU 4101 Ali and Baba (思路好题)

    与其说这是个博弈,倒不如说是个搜索.这题思路不错,感觉很难把情况考虑周全. 在地图外围填充一圈0,两次BFS,第一次从-1点出发,把从-1到达的0点以及包围0的那一圈石头标记出来.如下图: 1 1 1 ...

  5. react生命周期方法

    Mounting阶段,当一个组件的实例被创建并插入到DOM中时,下面这些函数会被调用: constructor() componentWillMount:组件即将被渲染到页面上,render之前最后一 ...

  6. Android记事本09

    昨天: Activity的数据传递. 今天: 从Activity中返回数据 请求码和返回码的作用 遇到的问题: 无.

  7. 安装bcc

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D4284CDD echo "deb https://repo.i ...

  8. easyUI tree jQuery

    Tree 数据转换 所有节点都包含以下属性: id:节点id,这个很重要到加载远程服务器数据 which is important to load remote data text: 显示的节点文本 ...

  9. Redis 与 Spring 集成

    配置applicationContext.xml <!-- 连接池配置 --> <bean id="jedisPoolConfig" class="re ...

  10. 项链 [FFT]

    题面 思路 这题很像bzoj4827礼物 还是一样的思路,我们把$y$倍长,$y[i+k]=y[i]+n$ 然后令$f(s,c)$表示从$y$的第$s$个开始匹配,位置偏移量为$c$的答案 可以得到$ ...