记录编号 |
598190 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[清华集训 2012] 模积和 |
最终得分 |
100 |
用户昵称 |
郑霁桓 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.130 s |
提交时间 |
2025-01-20 22:37:26 |
内存使用 |
3.34 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
long long a,b,s,s1,s2,as,M=19940417,a2=9970209,a6=3323403;
long long f(long long x){
return x*(x+1)%M*(2*x+1)%M*a6%M;
}
int main(){
freopen("modmuladd.in","r",stdin);
freopen("modmuladd.out","w",stdout);
ios::sync_with_stdio(false);
cin>>a>>b;
if(a>b) swap(a,b);
for(long long i=1,j;i<=a;i=j+1){
j=a/(a/i);
s1+=(i+j)*(j-i+1)%M*a2%M*(a/i)%M;
s1%=M;
}
for(long long i=1,j;i<=b;i=j+1){
j=b/(b/i);
s2+=(i+j)*(j-i+1)%M*a2%M*(b/i)%M;
s2%=M;
}
as=(a*a%M-s1+M)%M*(b*b%M-s2+M)%M;
s1=s2=0;
for(long long i=1,j;i<=a;i=j+1){
j=min(a/(a/i),b/(b/i));
s1+=(a*b%M*(j-i+1)%M+(a/i)%M*(b/i)%M*(f(j)-f(i-1)))%M;
s2+=(i+j)*(j-i+1)%M*a2%M*((a/i)%M*b%M+(b/i)%M*a%M)%M;
s1%=M,s2%=M;
}
as=(as-s1+s2+M)%M;
cout<<as%M;
return 0;
}