首页 > 其他分享 >Codeforces875A-Classroom Watch

Codeforces875A-Classroom Watch

时间:2022-11-22 19:35:01浏览次数:30  
标签:Codeforces875A Classroom begin end Watch number longint ans first


Classroom Watch

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

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

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

In next k

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.



题意:定义函数:f(x) = x + 十进制下x各位上的数字之和。给你f(x)的值(f(x) <= 1e9),让你输出所有可能的x值。题解:第三题似乎也很简单。我们直接从n-120到n枚举答案就可以了。


Code:var n,i,x,ans,k:longint;q:array[0..1000]of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a);
exit(b);
end;
begin
readln(n);
for i:=max(n-120,0) to n do
begin
x:=i;ans:=i;
while x>0 do
begin
ans:=ans+x mod 10;
x:=x div 10;
end;
if ans=n then begin inc(k);q[k]:=i;end;
end;
writeln(k);
for i:=1 to k do writeln(q[i]);
end.

标签:Codeforces875A,Classroom,begin,end,Watch,number,longint,ans,first
From: https://blog.51cto.com/u_15888102/5878381

相关文章

  • watch 和 computed
     1.computed的特点和用法 特点:(1)支持缓存:默认走缓存,多次调用,只会执行一次计算。只有依赖的数据发生改变,才会重新计算;(2)不支持异步,如果有异步操作......
  • vue2 计算属性9 watch immediate
    watch:监听数据发生的变化 newVal是变化后的新值,oldVal是变化前的旧值 一般都是带着接口查询的watch:{username(newVal){if(newVal==='')return$get('https:......
  • Vue3笔记 - Vue3中的计算属性、监视属性和watchEffect函数
    计算属性与监视属性目录计算属性与监视属性1.计算属性2.监视属性3.watchEffect函数1.计算属性Vue3中的计算属性仅在书写方式上与Vue2略有不同,功能上基本一致Vue2......
  • ue3中的watch的用法
    watch函数收三个参数:需要进行监听的数据的数组,监听的数据发生改变时的回调配置项一、监听基础类型二、监听复杂类型复杂类型的监听有很多种情况,具体的内容如......
  • 使用Stopwatch统计程序执行时间
    编程时,常常需要统计某段程序执行的时长,可以使用以下方法:Stopwatchsw=Stopwatch.StartNew();sw.Start();//需要执行的程序片段sw.Stop();Console.WriteLine("运行时......
  • Vue笔记 - 计算属性(computed)和监视属性(watch)
    计算属性和监视属性目录计算属性和监视属性1.计算属性2.监视属性2.1深度监视3.computed和watch对比1.计算属性定义:使用的属性起初并不存在,要通过已有属性计算得......
  • vue3 基础-API-watch 和 watchEffect
    watch和watchEffect前篇对computed属性如何在api中基本使用,即从vue中引入,然后通过直接传函数或者传对象的方式,开箱即用,非常清晰易......
  • 如何使用C# Stopwatch 测量微秒级精确度
    跟同事讨论到-用C#Stopwatch取得效能数值,Stopwatch.ElapsedMilliseconds只到毫秒(ms),如果需要更高的时间精确度(微秒μs,甚至奈秒ns),该怎么做?原以为要费番功夫,在Stacko......
  • CodeForces - 372C Watching Fireworks is Fun
    题意:有n个点,其中m个要放烟花。每个放烟花的点有属性b[i],放的时间t[i]和位置a[i]。假设放烟花的时候你在位置x,那么可以获得快乐b[i]-|x-a[i]|。你走来走去地看烟花,起始位置......
  • Vue 中 watch 监听器与 computed 计算属性的使用
    一、watch:监视单个属性,可做简单监视和深度监视。根据数据的具体结构,决定是否采用深度监视。配置deep:true可以监测对象内部值的改变,做深度监视时使用。1、简单监视:监视单......