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. IdentityServer(11)- 使用Hybrid Flow并添加API访问控制

    关于Hybrid Flow 和 implicit flow 我在前一篇文章使用OpenID Connect添加用户认证中提到了implicit flow,那么它们是什么呢,它和Hybrid Flow有 ...

  2. RHM-M60型挖掘机力矩限制器/载荷指示器

    RHM-M60挖掘机力矩限制器RHM-M60 excavator crane moment limiter     RHM-M60型挖掘机力矩限制器是臂架型起重机机械的安全保护装置,本产品采用32位高 ...

  3. 全面总结: Golang 调用 C/C++,例子式教程

    作者:林冠宏 / 指尖下的幽灵 掘金:https://juejin.im/user/587f0dfe128fe100570ce2d8 博客:http://www.cnblogs.com/linguan ...

  4. Object.prototype.toString.call()方法浅谈

    使用Object.prototype上的原生toString()方法判断数据类型,使用方法如下: Object.prototype.toString.call(value) 1.判断基本类型: Obj ...

  5. [国嵌笔记][006][Linux文本编辑器]

    Linux中常见的文本编辑器有Vi和Emacs Vim有3中工作模式:命令行模式.插入模式.底行模式 1.键入i进入插入模式 2.键入[Esc]退回到命令行模式 3.键入:进入底行模式,再键入wq保存 ...

  6. vue-cli创建的项目中引入第三方库报错 'caller', 'calle', and 'arguments' properties may not be...

    http://blog.csdn.net/sophie_u/article/details/76223978 以在vue中引入mui第三方库为例: 虽然针对vue,有单独的vue-mui库可以使用,但 ...

  7. Html5+js测试题(开发版)

    ------------------------------------------------ 1. 谈谈你对js闭包的理解: 使用闭包主要是为了设计私有的方法和变量.闭包的优点是可以避免全局变量的 ...

  8. 单独编译IMX6Q的VPU示例程序:mxc_vpu_test.out

    mxc_vpu_test.out是飞思卡尔为IMX6Q编写的VPU示例程序,有编解码和简单的网络传输功能. 首先从/opt/freescale/pkgs/中提取出imx-test-3.0.35-4.1 ...

  9. ADO.NET复习总结(2)--连接池

    1. 2. 3.示例:在一百次循环中,执行数据库连接的打开和关闭,使用stopwatch查看所用的时间. using System; using System.Collections.Generic; ...

  10. iOS学习之Map,定位,标记位置的使用

    iOS上使用地图比Android要方便,只需要新建一个MKMapView,addSubView即可.这次要实现的效果如下: 有标注(大头针),定位,地图. 1.添加地图 1.1 新一个Single V ...