codeforces-scrape

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

715A.md (5857B)


      1 Source: https://codeforces.com/problemset/problem/715/A
      2 
      3 A. Plus and Square Root
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' (square root). Initially, the number 2 is displayed on the screen. There are *n* + 1 levels in the game and ZS the Coder start at the level 1.
     22 
     23 When ZS the Coder is at level *k*, he can :
     24 
     25 1. Press the ' + ' button. This increases the number on the screen by exactly *k*. So, if the number on the screen was *x*, it becomes *x* + *k*.
     26 2. Press the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button. Let the number on the screen be *x*. After pressing this button, the number becomes ![](https://espresso.codeforces.com/dd68ff2d8e5b97302506ac32d308bb521ab84a26.png). After that, ZS the Coder levels up, so his current level becomes *k* + 1. This button can only be pressed when *x* is a perfect square, i.e. *x* = *m*2 for some positive integer *m*.
     27 
     28 Additionally, after each move, if ZS the Coder is at level *k*, and the number on the screen is *m*, then *m* must be a multiple of *k*. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5.
     29 
     30 ZS the Coder needs your help in beating the game — he wants to reach level *n* + 1. In other words, he needs to press the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button *n* times. Help him determine the number of times he should press the ' + ' button before pressing the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button at each level.
     31 
     32 Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level *n* + 1, but not necessarily a sequence minimizing the number of presses.
     33 
     34 Input
     35 
     36 The first and only line of the input contains a single integer *n* (1 ≤ *n* ≤ 100 000), denoting that ZS the Coder wants to reach level *n* + 1.
     37 
     38 Output
     39 
     40 Print *n* non-negative integers, one per line. *i*-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button at level *i*.
     41 
     42 Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018.
     43 
     44 It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them.
     45 
     46 Examples
     47 
     48 Input
     49 
     50 ```
     51 3
     52 ```
     53 
     54 Output
     55 
     56 ```
     57 14  
     58 16  
     59 46
     60 ```
     61 
     62 Input
     63 
     64 ```
     65 2
     66 ```
     67 
     68 Output
     69 
     70 ```
     71 999999999999999998  
     72 44500000000
     73 ```
     74 
     75 Input
     76 
     77 ```
     78 4
     79 ```
     80 
     81 Output
     82 
     83 ```
     84 2  
     85 17  
     86 46  
     87 97
     88 ```
     89 
     90 Note
     91 
     92 In the first sample case:
     93 
     94 On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button, and the number became ![](https://espresso.codeforces.com/c3d2663f5f74e9220fd5cbccbfaf4ca76ef7284f.png).
     95 
     96 After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button, levelling up and changing the number into ![](https://espresso.codeforces.com/49ab1d31f1435b7c7b96550d63a35be671d3d85a.png).
     97 
     98 After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button, levelling up and changing the number into ![](https://espresso.codeforces.com/499b57d4b7ba5e1e0957767cc182808ca48ef722.png).
     99 
    100 Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4.
    101 
    102 Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button is pressed, the number becomes ![](https://espresso.codeforces.com/49ab1d31f1435b7c7b96550d63a35be671d3d85a.png) and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution.
    103 
    104 In the second sample case:
    105 
    106 On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button, and the number became ![](https://espresso.codeforces.com/f07f2a60ab6cecbd2507861a0df57a16a015fd86.png).
    107 
    108 After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '![](https://espresso.codeforces.com/c77ded9b8209a8cb488cc2ec7b7fe1dae32a5309.png)' button, levelling up and changing the number into ![](https://espresso.codeforces.com/4c4d8829d987a7bcfd597cd1aa101327a66c0eca.png).
    109 
    110 Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.