The problem is calculate nCk with n <= 10^18, k <= 10^6 and mod = 10^9 + 7. Can anyone give me some hints or pesudo code. Thanks
# | User | Rating |
---|---|---|
1 | tourist | 3805 |
2 | maroonrk | 3637 |
3 | Benq | 3513 |
4 | ecnerwala | 3506 |
5 | MiracleFaFa | 3466 |
6 | slime | 3428 |
7 | jiangly | 3415 |
8 | Radewoosh | 3399 |
9 | greenheadstrange | 3393 |
10 | djq_cpp | 3391 |
# | User | Contrib. |
---|---|---|
1 | awoo | 192 |
2 | -is-this-fft- | 191 |
3 | Monogon | 185 |
4 | Um_nik | 182 |
4 | YouKn0wWho | 182 |
6 | maroonrk | 170 |
7 | antontrygubO_o | 168 |
8 | errorgorn | 166 |
8 | kostka | 166 |
8 | SecondThread | 166 |
The problem is calculate nCk with n <= 10^18, k <= 10^6 and mod = 10^9 + 7. Can anyone give me some hints or pesudo code. Thanks
Name |
---|
Maybe this will help https://www.geeksforgeeks.org/compute-ncr-p-set-3-using-fermat-little-theorem/
No, it can't work because we can't calulate n!.
just calc,k is small
n!/(n-k)!k!
as (n-k) is big, you can do simplify
oh, ok thanks u