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. 每日Scrum--No.2

    Yesterday:找地图 Today: 找到最适合我们软件的地图版本 Problem:找不到特别匹配的版本

  2. OOP 1.3 动态内存分配

    1.new运算符用法 分配一个变量:P=new T; T是任意类型名,P是类型为T的指针.动态分配出一片大小为sizeof(T)字节的内存空间,将该空间的起始地址赋值给P(new T的返回值为 T). ...

  3. Alpha 冲刺(8/10)

    队名 火箭少男100 组长博客 林燊大哥 作业博客 Alpha 冲鸭鸭鸭鸭鸭鸭鸭鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 协调各成员之间的工作 多次测试软件运行 学习OPENMP ...

  4. Java 更改日期格式

    import java.util.*; import java.text.*; public class TestDateFormat { public static void main(String ...

  5. TCP系列45—拥塞控制—8、SACK关闭的拥塞撤销与虚假快速重传

    一.概述 这篇文章介绍一下TCP从Recovery状态恢复到Open状态的时候cwnd的更新.我们在tcp重传部分的文章中曾经介绍过虚假重传的概念,Linux在探测到虚假重传的时候就会执行拥塞撤销操作 ...

  6. 三层神经网络自编码算法推导和MATLAB实现 (转载)

    转载自:http://www.cnblogs.com/tornadomeet/archive/2013/03/20/2970724.html 前言: 现在来进入sparse autoencoder的一 ...

  7. beta-review阶段贡献分分配

    小组名称:飞天小女警 项目名称:礼物挑选小工具 小组成员:沈柏杉(组长).程媛媛.杨钰宁.谭力铭 bera-review阶段各组员的贡献分分配如下: 姓名 团队贡献分 程媛媛 5.8 沈柏杉 6.1 ...

  8. 【Leetcode】322. Coin Change

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  9. c语言基础笔记

    一 :数据类型 1.float类型,在输出的时候可以使用 .数字  来把浮点数精确到小数点后几位,比如 printf("%.3f",float)精确到小数点后三位,不足补0 2.字 ...

  10. 【.Net】C#获取Windows系统特殊文件夹的路径

    系统特殊文件夹是包含公共信息的文件夹,如“Program Files”.“Programs”.“System”或“Startup”.特殊文件夹在默认情况下由系统设置,或者由用户在安装 Windows ...