codeforces-scrape

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

707C.md (1680B)


      1 Source: https://codeforces.com/problemset/problem/707/C
      2 
      3 C. Pythagorean Triples
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
     22 
     23 For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
     24 
     25 Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
     26 
     27 Katya had no problems with completing this task. Will you do the same?
     28 
     29 Input
     30 
     31 The only line of the input contains single integer *n* (1 ≤ *n* ≤ 109) — the length of some side of a right triangle.
     32 
     33 Output
     34 
     35 Print two integers *m* and *k* (1 ≤ *m*, *k* ≤ 1018), such that *n*, *m* and *k* form a Pythagorean triple, in the only line.
     36 
     37 In case if there is no any Pythagorean triple containing integer *n*, print  - 1 in the only line. If there are many answers, print any of them.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3
     45 ```
     46 
     47 Output
     48 
     49 ```
     50 4 5
     51 ```
     52 
     53 Input
     54 
     55 ```
     56 6
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 8 10
     63 ```
     64 
     65 Input
     66 
     67 ```
     68 1
     69 ```
     70 
     71 Output
     72 
     73 ```
     74 -1
     75 ```
     76 
     77 Input
     78 
     79 ```
     80 17
     81 ```
     82 
     83 Output
     84 
     85 ```
     86 144 145
     87 ```
     88 
     89 Input
     90 
     91 ```
     92 67
     93 ```
     94 
     95 Output
     96 
     97 ```
     98 2244 2245
     99 ```
    100 
    101 Note
    102 
    103 ![](https://espresso.codeforces.com/dbf52eca60c009fe6de5fd0bbce69fbd861fd8e9.png)
    104 
    105 Illustration for the first sample.