codeforces-scrape

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

30A.md (1549B)


      1 Source: https://codeforces.com/problemset/problem/30/A
      2 
      3 A. Accounting
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself.
     22 
     23 The total income *A* of his kingdom during 0-th year is known, as well as the total income *B* during *n*-th year (these numbers can be negative — it means that there was a loss in the correspondent year).
     24 
     25 King wants to show financial stability. To do this, he needs to find common coefficient *X* — the coefficient of income growth during one year. This coefficient should satisfy the equation:
     26 
     27 *A*·*X**n* = *B*.
     28 
     29 Surely, the king is not going to do this job by himself, and demands you to find such number *X*.
     30 
     31 It is necessary to point out that the fractional numbers are not used in kingdom's economy. That's why all input numbers as well as coefficient *X* must be integers. The number *X* may be zero or negative.
     32 
     33 Input
     34 
     35 The input contains three integers *A*, *B*, *n* (|*A*|, |*B*| ≤ 1000, 1 ≤ *n* ≤ 10).
     36 
     37 Output
     38 
     39 Output the required integer coefficient *X*, or «No solution», if such a coefficient does not exist or it is fractional. If there are several possible solutions, output any of them.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 2 18 2
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 3
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 -1 8 3
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 -2
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 0 0 10
     71 ```
     72 
     73 Output
     74 
     75 ```
     76 5
     77 ```
     78 
     79 Input
     80 
     81 ```
     82 1 16 5
     83 ```
     84 
     85 Output
     86 
     87 ```
     88 No solution
     89 ```