codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

460B.md (1404B)


      1 Source: https://codeforces.com/problemset/problem/460/B
      2 
      3 B. Little Dima and Equation
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment.
     22 
     23 Find all integer solutions *x* (0 < *x* < 109) of the equation:
     24 
     25 *x* = *b*·*s*(*x*)*a* + *c*, 
     26 
     27 where *a*, *b*, *c* are some predetermined constant values and function *s*(*x*) determines the sum of all digits in the decimal representation of number *x*.
     28 
     29 The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: *a*, *b*, *c*. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem.
     30 
     31 Input
     32 
     33 The first line contains three space-separated integers: *a*, *b*, *c* (1 ≤ *a* ≤ 5; 1 ≤ *b* ≤ 10000;  - 10000 ≤ *c* ≤ 10000).
     34 
     35 Output
     36 
     37 Print integer *n* — the number of the solutions that you've found. Next print *n* integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 109.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3 2 8
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 3  
     51 10 2008 13726
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 1 2 -18
     58 ```
     59 
     60 Output
     61 
     62 ```
     63 0
     64 ```
     65 
     66 Input
     67 
     68 ```
     69 2 2 -1
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 4  
     76 1 31 337 967
     77 ```