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.
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 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 134 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
| 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