Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def go(n, a, d, r, mod):
- mod *= (1 - r) * (1 - r)
- ret = (1 - r % mod) * ((a % mod - (a % mod + n % mod * d % mod) % mod * pow(r % mod, n + 1, mod) % mod) % mod) % mod
- ret += d % mod * r % mod * (1 - pow(r, n, mod)) % mod;
- if (ret > mod): ret -= mod
- ret //= ((1 - r) * (1 - r))
- mod //= (1 - r) * (1 - r)
- if (ret >= mod): print("NOOOO")
- return ret
- print(go(10**9+69 , 105253, 330787, 179948, 10**9 + 7))
- print(go(10 ** 18, 705000020383, 100000023986, 3746166374021812690, 2717401869))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement