codeforces-scrape

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

1184A1.md (1450B)


      1 Source: https://codeforces.com/problemset/problem/1184/A1
      2 
      3 A1. Heidi Learns Hashing (Easy)
      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 Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill the Eleventh Doctor.
     22 
     23 Heidi figured out that Madame Kovarian uses a very complicated hashing function in order to change the names of the babies she steals. In order to prevent this from happening to future Doctors, Heidi decided to prepare herself by learning some basic hashing techniques.
     24 
     25 The first hashing function she designed is as follows.
     26 
     27 Given two positive integers $(x, y)$ she defines $H(x,y):=x^2+2xy+x+1$.
     28 
     29 Now, Heidi wonders if the function is reversible. That is, given a positive integer $r$, can you find a pair $(x, y)$ (of positive integers) such that $H(x, y) = r$?
     30 
     31 If multiple such pairs exist, output the one with smallest possible $x$. If there is no such pair, output "NO".
     32 
     33 Input
     34 
     35 The first and only line contains an integer $r$ ($1 \le r \le 10^{12}$).
     36 
     37 Output
     38 
     39 Output integers $x, y$ such that $H(x,y) = r$ and $x$ is smallest possible, or "NO" if no such pair exists.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 19
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 1 8
     53 ```
     54 
     55 Input
     56 
     57 ```
     58 16
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 NO
     65 ```