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.

从n-n的位数*9到n枚举就行了;

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std; int n,ans[],res,k; int main(){
scanf("%d",&n);
long long g=,gg=;
while(g<=n){
g=g*+;
gg++;
}
gg+=;
for(int i=n-gg*;i<=n;i++){
int x=n-i,a=i;
while(a>){
x=x-a%;
a=a/;
}
if(x==){
res++;
ans[res]=i;
}
}
printf("%d\n",res);
for(int i=;i<=res;i++)
printf("%d\n",ans[i]);
}

Codeforces C. Classroom Watch的更多相关文章

  1. Codeforces 876C Classroom Watch:枚举

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

  2. CodeForces - 876C Classroom Watch (枚举)

    题意:已知n,问满足条件"x的各个数字之和+x=n"的x有几个并按升序输出. 分析: 1.n最大1e9,10位数,假设每一位都为9的话,可知x的各个数字之和最大可以贡献90. 2. ...

  3. codeforces 876 C. Classroom Watch

    http://codeforces.com/contest/876/problem/C C. Classroom Watch time limit per test 1 second memory l ...

  4. 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 ...

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

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

  6. Codeforces 1166A - Silent Classroom

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

  7. Codeforces Round #561 (Div. 2) A. Silent Classroom(贪心)

    A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard inp ...

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

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

  9. 「Codeforces Round #441」 Classroom Watch

    Discription Eighth-grader Vova is on duty today in the class. After classes, he went into the office ...

随机推荐

  1. ScheduledThreadPoolExecutor详解

    本文主要分为两个部分,第一部分首先会对ScheduledThreadPoolExecutor进行简单的介绍,并且会介绍其主要API的使用方式,然后介绍了其使用时的注意点,第二部分则主要对Schedul ...

  2. 在做vue计算属性,v-for处理数组时遇到的一个bug

    bug: You may have an infinite update loop in a component render function 无限循环 需要处理的数组(在 ** ssq **里): ...

  3. AdaBoostRegressor

    class sklearn.ensemble.AdaBoostRegressor(base_estimator=None, n_estimators=50, learning_rate=1.0, lo ...

  4. deeplearning.ai 人工智能行业大师访谈 Geoffrey Hinton 听课笔记

    1. 怀揣着对大脑如何存储记忆的好奇,Hinton本科最开始学习生物学和物理学,然后放弃,转而学习哲学:然后觉得哲学也不靠谱,转而学习心理学:然后觉得心理学在解释大脑运作方面也不给力,转而做了一段时间 ...

  5. 【Python】爬虫-Scrapy

    [Scrapy] Python开发的一个快速,高层次的屏幕抓取和web抓取框架,用于抓取web站点并从页面中提取结构化的数据. Scrapy用途广泛,可以用于数据挖掘.监测和自动化测试. Scrapy ...

  6. 文件末尾判断feof

    feof 作用:如果文件结束,则返回非0值,否则返回0 但要注意的是feof要读取到文件结束标志EOF后,才能判断文件是否结束. 所以使用while(!feof(pFile))会出现最后fread会返 ...

  7. 在echarts3中使用字符云

    echarts2的官方API里是带有字符云的,但到了echarts3就被从官网上移除了,想要使用的话可以从github上下载: 下载地址:https://github.com/ecomfe/echar ...

  8. UE4 多线程(一)

    UE4中使用多线程的有两种方式,一种方式就是使用FRunnable和FRunnableThread,另一种方式是Task Graph System.Task Graph System有时会占用游戏线程 ...

  9. .27-浅析webpack源码之事件流make(2)

    上一节跑到了NormalModuleFactory模块,调用了原型方法create后,依次触发了before-rsolve.factory.resolver事件流,这节从resolver事件流开始讲. ...

  10. php对数组进行分页

      3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...