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. UVALive 4764 简单dp水题(也可以暴力求解)

    B - Bing it Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status ...

  2. A - 最长上升子序列

    A - 最长上升子序列 Time Limit: 1000/1000MS (C++/Others) Memory Limit: 65536/65536KB (C++/Others) Problem De ...

  3. table纵横都需要下拉框

    table 溢出,下拉框显示不全 <div class="table-scrollable"style="height: 500px; overflow-y: vi ...

  4. Web 安全概念

    Web 安全概念 Web 应用中存在很多安全风险,这些风险会被黑客利用,轻则篡改网页内容,重则窃取网站内部数据,更为严重的则是在网页中植入恶意代码,使得用户受到侵害.常见的安全漏洞如下: XSS 攻击 ...

  5. objective-c runtime 开发详情

    目录 概述 对象与类的实质 id与class 继承关系与isa 总结 C函数创建一个OC类 OC类与runtime NSObjectProtocol NSObject NSProxy 一.概述 Obj ...

  6. Redux & React & react-redux

    Redux Redux & React & react-redux https://redux.js.org/ https://redux.js.org/api https://red ...

  7. 2-sat 学习笔记

    一.问题描述 以你咕的模板题为例 题目描述 有\(n\)个布尔变量\(x_1\)~\(x_n\),另有\(m\)个需要满足的条件,每个条件的形式都是"\(x_i\)为true/false或\ ...

  8. 熊猫(i)

    题目描述 熊猫喜欢吃数,熊猫对与每个数都有他独特的评价.具体来说,熊猫对数 xx 的评价是个四元组 (a, b, c, d)(a,b,c,d),计算方式如下: 首先将 xx 写成二进制形式(不含前导零 ...

  9. 在linux中启动mysql服务的命令

    用reboot命令重启linux服务器之后会导致mysql服务终止,也就是mysql服务没有启动.必须要重启mysql服务,否则启动jboss时会 报有关数据库mysql方面的错误. 命令如下: 第一 ...

  10. 网络嗅探器Wireshark

    http://www.wireshark.org/   About Wireshark Wireshark is the world's foremost network protocol analy ...