Solution: 17571360 | CodeChef <—solution
Contest Page | CodeChef <----problem
Getting WA! i think there is a small flaw maybe could you check where am i going wrong? i used 100 testcases from a generator and ran through it my code and a correct code, they matched perfectly! i dont know what’s wrong.
Ohk! got it…
For this test:
1
5550
Your code output 7. The correct answer is 5 (37,74,75,370,2775 are the lucky numbers). Your code counted 74 and 75 twice.
This can be handled by changing math.ceil(inp**0.5) to math.floor(inp**0.5).
Also, for this case
16
correct answer is 1 (the lucky number is 4). Your code counted 4 twice.
To avoid this, change if j!=inp//2 to if inp!=j*j.
I’ve rewritten your code and got Accepted. Link:https://www.codechef.com/viewsolution/17626825