I can't get accepted for this problem. I've written a slow brute-force to check against my WA code, and they give the same answer for every random input I generated.
It's interesting to see that my code dies for exactly one input case at the judge! (By "die" I mean it fails to give a matching n. I've put loops in my code to verify this

- EDIT -
Found a pretty stupid flaw... Will try to fix that tmr~


- EDIT -
Fixed. Got AC. Some I/O here:
Code: Select all
10000000
100000000
99450756
99038478
993012
800000
8000000
0
Code: Select all
Case 1: 10000000 10165751
Case 2: 100000000 100064101
Case 3: 99450756 99460729
Case 4: 99038478 99252847
Case 5: 993012 994009
Case 6: 800000 1000625
Case 7: 8000000 10000625