收获:

  1、当一个东西的取值范围很小时,或者感觉它很麻烦时,就枚举它

  2、熟悉mobius函数、euler函数的和函数,以及euler函数用mobius函数的表示。

  3、下取整分块理解更深了。

 /**************************************************************
Problem: 2154
User: idy002
Language: C++
Result: Accepted
Time:5584 ms
Memory:157916 kb
****************************************************************/ #include <cstdio>
#include <iostream>
#define M 20101009
using namespace std; typedef long long dnt; int prm[], isnot[], mu[], ptot;
dnt mds[]; void init( int n ) {
mu[] = ;
for( int i=; i<=n; i++ ) {
if( !isnot[i] ) {
prm[++ptot] = i;
mu[i] = -;
}
for( int j=; j<=ptot && i*prm[j]<=n; j++ ) {
isnot[i*prm[j]] = true;
if( i%prm[j]== ) {
mu[i*prm[j]] = ;
break;
}
mu[i*prm[j]] = -mu[i];
}
}
for( dnt d=; d<=n; d++ ) {
mds[d] = (mu[d]*d*d)%M;
mds[d] += mds[d-];
if( mds[d]>=M ) mds[d]-=M;
if( mds[d]< ) mds[d]+=M;
}
} inline dnt S( dnt x, dnt y ) {
return (((+x)*x/%M)*(((+y)*y)/%M)%M);
}
dnt F( dnt x, dnt y ) {
if( x>y ) swap(x,y);
dnt rt = ;
for( dnt d=; d<=x; d++ ) {
dnt dd = min( x/(x/d), y/(y/d) );
rt += S(x/d,y/d) * (mds[dd]-mds[d-]) % M;
if( rt< ) rt += M;
if( rt>=M ) rt -= M;
d = dd;
}
return rt;
}
dnt calc( dnt n, dnt m ) {
if( n>m ) swap(n,m);
dnt rt = ;
for( dnt d=; d<=n; d++ ) {
dnt dd=min( n/(n/d), m/(m/d) );
rt += ((d+dd)*(dd-d+)/ % M) * F( n/d, m/d ) % M;
if( rt< ) rt+=M;
if( rt>=M ) rt-=M;
d = dd;
}
return rt;
}
int main() {
int n, m;
scanf( "%d%d", &n, &m );
if( n>m ) swap(n,m);
init(n);
printf( "%lld\n", calc(n,m) );
}

最新文章

  1. POI对Excel自定义日期格式的读取
  2. mysql数据导出excel格式+乱码解决
  3. handsontable组件和jqwidgets(jqxdragdrop组件)在一个页面产生调整宽高bug
  4. 行转列一定要sum
  5. JAVA模块化
  6. Netty 5 传送大文件的方法
  7. 通常编译亲测56Y国际象棋源代码,精仿56Y国际象棋完整的源代码下载!
  8. IOS应用上传须要做的工作
  9. C# 常用接口学习 IComparable 和 IComparer
  10. 传感器系列之4.12GPS定位传感器
  11. [原创]Nexus5 源码下载、编译、真机烧录过程记录
  12. 『OGG 03』Win7 配置 Oracle GoldenGate 一次性成功(包括Adapter Java)
  13. Esptouch移植xamarin记要
  14. 支持向量机(Support Vector Machine):超平面
  15. Confluence 6 虚拟文件和文件夹
  16. mysql 在update中实现子查询的方式
  17. react-native绑定优酷SDK-附效果图和源码
  18. 使用不同模板引擎beetl、FreeMarker、Velocity动态解析sql的方法
  19. 【RF库Collections测试】Dictionary Should Not Contain Key
  20. 在TFS 2013的迭代视图中修改工作项数目限制

热门文章

  1. spring mvc convention over configuration 之 RequestToViewNameTranslator
  2. Git其他的命令------(四)
  3. Tensorflow中使用TFRecords高效读取数据--结合Attention-over-Attention Neural Network for Reading Comprehension
  4. VueJS $refs 在 ElementUI 中遇到的问题
  5. sqlmap的使用方法 ——时光凉春衫薄
  6. php 全文搜索解决方法
  7. learnyounode 题解
  8. C# 多线程多文件批量下载---子线程中更新UI 实例
  9. 查看压缩包内容tar -tf
  10. spring mvc整合mybaitis和log4j