As 1h,wn{1 \le h, w \le n}, there are total n2n^2 possible area (1,2,3,,n2){(1, 2, 3, \dots, n^2)}. We can split it into sequential nn segments where length of each segment is nn {(1,,n),(n+1,,2n),(2n+1,,3n),,(n(n1)+1,,n2){(1, \dots, n), (n+1, \dots, 2n), (2n+1, \dots, 3n), \dots, (n(n-1)+1, \dots, n^2)}}.

At first, query on these segments and find secret area lies in which segment. It can be done with binary search on 1st1st segment to nthn−th segment. It takes at most 1010 queries.

Now, we’ve a nn length segment means nn possible area. Iterate on each area, take only valid area. Valid area means which integer has at least two divisors (divisors can be same) less than or equal to nn. Now binary search on valid area. It takes at most 1010 queries.

Statistics

32% Solution Ratio
YouKnowWhoEarliest, May '21
Kuddus.6068Fastest, 0.0s
utshabLightest, 176 kB
Tahmid690Shortest, 1024B
Toph uses cookies. By continuing you agree to our Cookie Policy.