Problem : https://codeforces.me/contest/1538/problem/D
Solution Link : https://codeforces.me/contest/1538/submission/119077891
Can anyone explain why I am getting TLE on test 6 for this solution?
Problem : https://codeforces.me/contest/1538/problem/D
Solution Link : https://codeforces.me/contest/1538/submission/119077891
Can anyone explain why I am getting TLE on test 6 for this solution?
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | maspy | 150 |
| 3 | Um_nik | 146 |
| 4 | Errichto | 139 |
| 5 | adamant | 136 |
| 6 | maroonrk | 134 |
| 7 | DNR | 133 |
| 8 | Dominater069 | 131 |
| 9 | Proof_by_QED | 130 |
| 9 | AmShZ | 130 |
| Название |
|---|



I get TLE like you too. But after I changed using long long to int then I got AC.
This problem is so weird that you got AC when you use int but get TLE when you use long long
yeah I got AC too. But why long long is leading to TLE?
The time to process with long long is a little bit longer than that of int. So using int can speed up your program for a little bit and got AC in cases that your program execution time exceed the time limit with a very small amount of time.
Yeah, I remember one of the dp problems in CSES having the same problem, took me a long time to figure out what went wrong.
kshitijanand36 ..
I had the same problem. I fixed it by simply writing prime factorization (I counted all prime numbers from $$$2$$$ to $$$ \sqrt {10 ^ 9} $$$))
TL6: https://codeforces.me/contest/1538/submission/119027345
AC: https://codeforces.me/contest/1538/submission/119038949
i don't know why many people didn't get TLE with that solution. but as i know T*sqrt(1e9)*2 = 4e8 = 4seconds is TLE. at least, that's the reason for your TLE.
To be safe, you need to precalculate all prime numbers from 2 to sqrt(1e9) and only check thoses numbers.
Yes, I did the same and it worked