https://www.lydsy.com/JudgeOnline/problem.php?id=2956

https://www.luogu.org/problemnew/show/P2260

暴力推式子即可

 #include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll md=;
ll n,m,ans,a1,a2;
ll Mod(ll x,ll md=md)
{
if(x>=) return x%md;
else if(x%md==) return ;
else return md+x%md;
}
ll calc(ll x)
{
return (x)*(x+)%md*(*x+)%md*%md;
}
int main()
{
ll i,j;
scanf("%lld%lld",&n,&m);
if(n>m) swap(n,m); // {
// ll ams=0;
// for(ll i=1;i<=n;i++)
// for(ll j=1;j<=m;j++)
// if(i!=j)
// ams=Mod(ams+(n-n/i*i)*(m-m/j*j));
// printf("%lld",ams);
// return 0;
// } for(i=;i<=n;i=j+)
{
j=n/(n/i);
a1=Mod(a1+Mod((i+j)*(j-i+)/)*(n/i));
}
for(i=;i<=m;i=j+)
{
j=m/(m/i);
a2=Mod(a2+Mod((i+j)*(j-i+)/)*(m/i));
}
//printf("a%lld %lld\n",a1,a2); ans=Mod(ans+n*n%md*m%md*m%md);
ans=Mod(ans-n*n%md*a2%md);
ans=Mod(ans-m*m%md*a1%md);
ans=Mod(ans+a1*a2%md); ans=Mod(ans-n*n%md*m%md);
{
ll t=;
for(i=;i<=n;i=j+)
{
j=min(n,m/(m/i));
t=Mod(t+Mod((i+j)*(j-i+)/)*(m/i));
}
ans=Mod(ans+n*t%md);
}
ans=Mod(ans+m*a1%md);
{
ll t=;
for(i=;i<=n;i=j+)
{
j=min(n/(n/i),m/(m/i));
t=Mod(t+Mod(calc(j)-calc(i-))*(n/i)%md*(m/i));
}
//printf("t%lld\n",t);
ans=Mod(ans-t);
} printf("%lld",ans);
return ;
}

最新文章

  1. XE3随笔17:实例 - 模拟 Google 搜索
  2. 【数据压缩】Huffman编码
  3. Mango Weekly Training Round #6 解题报告
  4. 青瓷qici - H5小游戏 抽奖机 1 素材
  5. Reactor模式(反应器模式)
  6. 25045操作标准子程序集41.C
  7. Objective-C基础笔记(2)@property和@synthesize
  8. Exception in thread &amp;quot;main&amp;quot; java.lang.IllegalArgumentException
  9. ER模型的学习
  10. EF查询百万级数据的性能测试--多表连接复杂查询
  11. NetworkManager 冲突
  12. Linux内核数据结构之kfifo详解
  13. Java远程连接redis, 报错 Connection refused: connect
  14. OP社区相关
  15. linux---文件颜色含义
  16. 浏览器Hack演示
  17. MyBatis JavaType JdbcType
  18. leetcode python找不同
  19. [HDU4089]Activation(概率DP)
  20. poj 1962(并查集+带权更新)

热门文章

  1. LightOJ1336 Sigma Function —— 质因子分解、约数和为偶数
  2. PL/SQL DEVELOPER执行计划的查看
  3. C3P0 配置
  4. HttpClient入门教程
  5. javascript闭包和闭包的几种写法和用法
  6. vue-touchjs
  7. 安装 Sublime Text 3及其插件
  8. A - Combination Lock
  9. 【Hive】Hive笔记:Hive调优总结——数据倾斜,join表连接优化
  10. PHP实用小程序(五)