The problem: Find the nth number that has it's sum of digits divisible by 10. (n <= 10^15) I can only think of digit DP, but I'm trying to think of a simpler way. If anyone can help me, please do.
| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Kevin114514 | 3655 |
| 3 | Benq | 3650 |
| 4 | maroonrk | 3427 |
| 5 | strapple | 3413 |
| 6 | Um_nik | 3387 |
| 7 | heuristica | 3322 |
| 8 | tourist | 3301 |
| 9 | turmax | 3297 |
| 10 | squareOf105 | 3262 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | maspy | 150 |
| 2 | nik_exists | 150 |
| 4 | Um_nik | 145 |
| 5 | Errichto | 139 |
| 6 | adamant | 136 |
| 7 | maroonrk | 134 |
| 7 | AmShZ | 134 |
| 9 | BledDest | 133 |
| 10 | DNR | 131 |
The problem: Find the nth number that has it's sum of digits divisible by 10. (n <= 10^15) I can only think of digit DP, but I'm trying to think of a simpler way. If anyone can help me, please do.
| Name |
|---|



Have you tried to investigate how
sumOfDigits(n) % 10behaves when you iteraten = 1..100or something like this? You probably can come upon the idea...can you give me another hint pls
write out with paper and pencil, look for a pattern
maybe here is a simple way :
Try running it for
n=10^15yourselfI think it can be done in O(1): If k is the sum of digits of n, then the final answer will be concatenation of n and digit q = (10 — k % 10) % 10
yep, in other words, there should be one such number in any ten :)
thanks a lot
Another gray trying to solve dp before knowing how to sort array :((
I know how to sort array, but still cant solve dp :(
You can easily sort an array in $$$O(n^2)$$$ using DP... dp is like the foundation of competitive programming