I can do it in O(N) time. but can it be more faster?
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 163 |
| 2 | adamant | 149 |
| 3 | Um_nik | 145 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 135 |
| 7 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 132 |
I can do it in O(N) time. but can it be more faster?
| Name |
|---|



Use inclusion/exclusion principle.
floor(N / 3) + floor(N / 5) — floor(N / 15)
As you said below N. So N cannot be accounted for. The formula will be
floor((N-1)/3) + floor((N-1)/5) — floor((N-1)/LCM(3,5))