【bzoj3561】DZY Loves Math VI
来源:互联网 发布:欧式快热炉 油汀 知乎 编辑:程序博客网 时间:2024/05/18 00:12
题意:(第n次)略
(依然是)lych大大的题解
(最近越来越懒了)
吐槽:我一开始用T=pd带掉了,结果那一串函数发现不是积性的(似乎)。。于是gg了。后来发现想太多了(居然不是套路)。。
#include <bits/stdc++.h>#define gc getchar()#define ll long long#define N 500009#define mod 1000000007using namespace std;int n,m,mu[N],pri[N],pd[N],cnt,ans,sum[N],Ans,a[N];int read(){int x=1;char ch;while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;int s=ch-48;while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-48;return s*x;}int ksm(int y,int x){int ans=1;for (;x;x>>=1,y=(ll)y*y%mod)if (x&1) ans=(ll)ans*y%mod;return ans;}int main(){n=read(),m=read();if (n>m) swap(n,m);mu[1]=pd[1]=1;for (int i=2;i<N;i++){if (!pd[i]) pri[++cnt]=i,mu[i]=-1;for (int j=1;j<=cnt&&i*pri[j]<N;j++){pd[i*pri[j]]=1;if (i%pri[j]==0){mu[i*pri[j]]=0;break;}mu[i*pri[j]]=-mu[i];}}for (int i=1;i<=m;i++) a[i]=1;for (int d=1;d<=n;d++){ans=0;for (int p=1;p*d<=m;p++){a[p]=(ll)a[p]*p%mod;sum[p]=((ll)sum[p-1]+a[p])%mod;}for (int p=1;p*d<=n;p++)if (mu[p]) ans=((ll)ans+(ll)mu[p]*a[p]*a[p]%mod*sum[n/p/d]%mod*sum[m/p/d]%mod+mod)%mod;ans=(ll)ans*ksm(d,d)%mod;Ans=((ll)Ans+ans)%mod;}printf("%d\n",Ans);return 0;}
0 0
- BZOJ3561: DZY Loves Math VI
- 【bzoj3561】DZY Loves Math VI
- [bzoj3561] DZY Loves Math VI
- BZOJ3561: DZY Loves Math VI
- bzoj3561 DZY Loves Math VI
- bzoj3561 DZY Loves Math VI 莫比乌斯函数
- 2017.10.9 DZY Loves Math VI 失败总结
- 【BZOJ3309】DZY Loves Math
- BZOJ3309: DZY Loves Math
- bzoj3309: DZY Loves Math
- DZY Loves Math IV
- BZOJ3309: DZY Loves Math
- 【bzoj3309】DZY Loves Math
- bzoj3309 DZY Loves Math
- [bzoj3309] DZY Loves Math
- bzoj3309: DZY Loves Math
- bzoj3309 DZY Loves Math
- 3309: DZY Loves Math
- C++学习笔记
- Jetty基本原理
- ios开发者今天第一天来报道
- Java 日期操作
- Linux–Shell系列1_比较运算符
- 【bzoj3561】DZY Loves Math VI
- android--React-Native(Windows)中的配置
- linux读写cpu寄存器linux寄存器读linux操作cpu寄存器实例
- oracle基础学习02
- ionic2 轮播图
- 系统函数-文件操作-chmod()
- Hololens错误提示:can't be loaded because it was not built with the right version or build target.
- Codeforces Round #392 (Div. 2)-B. Blown Garland(水题)
- C#87课的主要内容