Skip to content

Instantly share code, notes, and snippets.

@snuke
Last active July 29, 2018 14:24
Show Gist options
  • Save snuke/c21d17ea8545bcc78dafe4017d841c57 to your computer and use it in GitHub Desktop.
Save snuke/c21d17ea8545bcc78dafe4017d841c57 to your computer and use it in GitHub Desktop.
TCO2018 Round4 Hardの本質部分
modint calc(long long s) { // returns sum(S[0] ... S[pos(s)-1])
modint res;
while (n <= s) {
res += sum(0, n);
s -= n;
s *= b;
}
res += sum(0, s);
return res;
}
ans[0] = calc(s*b+1) - calc(s*b);
ans[1] = calc(s*b) - calc(s*b-b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment