Mock CCC '22 Contest 1 J1 - Square Root Decomposition

View as PDF

Submit solution


Points: 3
Time limit: 0.25s
Memory limit: 256M

Author:
Problem type

Bob is practicing square root decomposition!

The problem Bob is doing involves breaking a number N into B groups. It is said to be optimal if B is closest to \sqrt{N}.

He currently has 2 candidates for B: integers i and j. If i and j are squared, which one is closer to N?

The data guarantee that one candidate will be closer than the other.

Constraints

1 \le N, i, j \le 10^4

i \ne j

Input Specification

The first line will contain N.

The second line will contain i.

The third and final line will contain j.

Output Specification

On one line, output 1 if i^2 is closer to N or 2 if j^2 is.

Sample Input 1

9
3
4

Sample Output 1

1

Sample Input 2

16
5
3

Sample Output 2

2

Comments


  • -1
    Raynfall  commented on Feb. 18, 2025, 12:22 a.m. edited

    Possible spoiler, but I had tried to square the distances between N and i/j squared to find the positive distance, but that caused a WA .Since the distances are being compared and their actual value doesn't matter, why wouldn't this work?


    • 0
      stephengzy___PYTHON  commented on Jan. 1, 2026, 8:33 p.m.

      Take i = 3, N = 4, j = 5

      Your solution would find a difference of 1 each, so it would assume that the two are the same distance apart.

      But 16-9 = 7 and 25-16 = 9, so your solution is incorrect.