标签:mba zlib mmc mfp cio +mvc phar bzoj spin
#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #include<iostream> #define mod 19940417 using namespace std; long long ans,n,m,ine; long long power(long long x,long long y) { long long ans=1; while (y) { if (y&1) ans=ans*x%mod; x=x*x%mod; y>>=1; } return ans; } long long sum(long long x) { return x*(x+1)/2%mod; } long long Sum(long long x) { return x*(x+1)%mod*(2*x+1)%mod*ine%mod; } long long cal(long long n) { long long ans=n*n%mod; long long last; for (long long i=1;i<=n;i=last+1) { last=n/(n/i); ans=(ans-(n/i)*(sum(last)-sum(i-1)+mod)%mod+mod)%mod; } return ans%mod; } int main() { scanf("%lld%lld",&n,&m); ine=3323403; if (n>m) swap(n,m); ans=cal(n)*cal(m)%mod; //计算式子1 [最好用long long,防止相乘时爆炸] long long last; for (long long i=1;i<=n;i=last+1) { last=min(n/(n/i),m/(m/i));//n/i=k,last=n/k ans=(ans-n*m%mod*(last-i+1)%mod+m*(n/i)%mod*(sum(last)-sum(i-1)+mod)%mod+n*(m/i)%mod*(sum(last)-sum(i-1)+mod)%mod-(n/i)*(m/i)%mod*(Sum(last)-Sum(i-1)+mod)%mod+2*mod)%mod; } printf("%lld\n",ans); return 0; }
标签:mba zlib mmc mfp cio +mvc phar bzoj spin
原文地址:http://www.cnblogs.com/Parry-PY/p/7642874.html