+ 7

I just tried to solve some cpp problems and in this solution there's something obnoxious :(

I solved this and it passes most of the test but it shows unaccepted or wrong answer..can someone find the loopholes in my code against the testcases or the complier is abnormal 🤔 Thanks. Problems link: https://www.codechef.com/JAN21C/problems/DIVTHREE Solution: https://code.sololearn.com/cwpNsgQc7uz0/?ref=app

9th Jan 2021, 3:09 PM
Aditya
Aditya - avatar
1 Réponse
+ 1
1. It's better to use "int" instead of "long long" because 32-bit int will be enough for this problem. 2. There's no need to use "floor" function for integers division. 3. You must consider the case "sum/k == d". result = sum / k; if (result > d) { cout << d << endl; } else { cout << result << endl; } I hope it helps.
11th Jan 2021, 6:09 PM
Mohammad Reza Sharifi Khorasani
Mohammad Reza Sharifi Khorasani - avatar