The staff,,, to seek the prefix and the time $ixi$ is int, and then when the $i=10^7$ will be loved to explode int,,, after the shooting of an afternoon to find this problem,,, the last enumeration with the variables are all forcibly plus a long long only a drop
#include <cstdio> #include <cstring> #include <algorithm> #define READ (x) X=getint () using namespace Std;typedef long Long ll;const int p = 20101009;const int N = 1E7 + 3;int getint () {int k = 0, fh = 1; char c = GetChar (); for (; c < ' 0 ' | | c > ' 9 '; c = GetChar ()) if (c = = '-') FH = -1;for (; c >= ' 0 ' && C <= ' 9 '; c = GetChar ( ) K = k * + C-' 0 '; return k * FH; BOOL Np[n];int Prime[n], mu[n], s[n];void shai (int N) {mu[1] = 1; s[1] = 1; int num = 0;for (int i = 2; I <= N; ++i) {if (!np[i]) {Mu[i] = -1;prime[++num] = i;} for (int j = 1; j <= Num; ++j) {int t = prime[j] * I;IF (T > N) break;np[t] = 1;if (i% prime[j] = 0) {Mu[t] = 0; BR Eak;} MU[T] =-mu[i];} S[i] = (S[i-1] + (1LL * I * i * mu[i])% p)% p;}} ll sum (ll X, ll y) {return ((((x * (x + 1)/2)% P) * ((Y * (y + 1)/2)% p))% p;} ll F (ll X, ll y) {ll re = 0;for (int i = 1, la = 1; i <= x; i = la + 1) {la = min (x/(x/i), Y/(y/i)); re = (re + ( S[la]-s[i-1]) * SUM (x/i, y/i)% p)% P;} return re;} int main () {int n, m;read (n); Read (m), if (n > M) swap (n, m); Shai (n); LL ret = 0;for (ll d = 1, la = 1; d <= n; d = la + 1) {la = min (n/(n/d), M/(M/D)); ret = (ret + (d + LA) * (LA- D + 1)/2 P * F (n/d, m/d)% p)% p;} printf ("%lld", (ret + p)% p); return 0;}
I don't know what to say ...
Digital table for "Bzoj 2154" crash