bzoj 2671 莫比乌斯反演
Calc
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 451 Solved: 234
[Submit][Status][Discuss]
Description
1.1<=a<b<=N
2.a+b整除a*b
Input
一行一个数N
Output
一行一个数表示答案
Sample Input
Sample Output
HINT
数据规模和约定
Test N Test N
1 <=10 11 <=5*10^7
2 <=50 12 <=10^8
3 <=10^3 13 <=2*10^8
4 <=5*10^3 14 <=3*10^8
5 <=2*10^4 15 <=5*10^8
6 <=2*10^5 16 <=10^9
7 <=2*10^6 17 <=10^9
8 <=10^7 18 <=2^31-1
9 <=2*10^7 19 <=2^31-1
10 <=3*10^7 20 <=2^31-1
Source
http://blog.csdn.net/popoqqq/article/details/45095601
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define ll long long
#define mod 1000000007
#define N 50005
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} bool flag[N];
int tot,p[N],miu[N],n,m,pos;
ll ans; void pre()
{
miu[]=;
for (int i=;i<N;i++)
{
if (!flag[i]) p[++tot]=i,miu[i]=-;
for (int j=;j<=tot&&p[j]*i<N;j++)
{
flag[i*p[j]]=;
if (i%p[j]==) break;
miu[i*p[j]]=-miu[i];
}
}
}
int main()
{
pre();
scanf("%d",&n);m=sqrt(n);
for (int d=;d<=m;d++)
{
for (int i=;i<=m/d;i++)
{
int last=n/(d*d*i);
for (int x=i+,p=;x<=*i-&&x<=last;x=pos+)
{
pos=last/(last/x);
ans+=1LL*miu[d]*(min(pos,*i-)-x+)*(last/x);
}
}
}
printf("%lld",ans);
}
bzoj 2671 莫比乌斯反演的更多相关文章
- 【题解】Crash的数字表格 BZOJ 2154 莫比乌斯反演
题目传送门 http://www.lydsy.com/JudgeOnline/problem.php?id=2154 人生中第一道自己做出来的莫比乌斯反演 人生中第一篇用LaTeX写数学公式的博客 大 ...
- BZOJ 3309 莫比乌斯反演
题目链接 https://www.lydsy.com/JudgeOnline/problem.php?id=3309 题意:定义f(n)为n所含质因子的最大幂指数,求 $Ans=\sum _{i=1} ...
- BZOJ 2301 莫比乌斯反演入门
2301: [HAOI2011]Problem b Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函 ...
- bzoj 2154 莫比乌斯反演求lcm的和
题目大意: 表格中每一个位置(i,j)填的值是lcm(i,j) , 求n*m的表格值有多大 论文贾志鹏线性筛中过程讲的很好 最后的逆元我利用的是欧拉定理求解的 我这个最后线性扫了一遍,勉强过了,效率不 ...
- bzoj 2301 莫比乌斯反演
对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 这里题目意思很明显 对于要求的f[n] = sig ...
- bzoj 1101 莫比乌斯反演
最裸的莫比乌斯 #include<bits/stdc++.h> #define LL long long #define fi first #define se second #defin ...
- bzoj 2820 莫比乌斯反演
搞了一整个晚自习,只是看懂了dalao们的博客,目前感觉没有思路-.还是要多切题 next day: 刚才又推了一遍,发现顺过来了,hahaha #include<cstdio> #inc ...
- BZOJ - 2818 莫比乌斯反演 初步
要使用分块的技巧 #include<iostream> #include<algorithm> #include<cstdio> #include<cstri ...
- bzoj 2820 / SPOJ PGCD 莫比乌斯反演
那啥bzoj2818也是一样的,突然想起来好像拿来当周赛的练习题过,用欧拉函数写掉的. 求$(i,j)=prime$对数 \begin{eqnarray*}\sum_{i=1}^{n}\sum_{j= ...
随机推荐
- (二)、Python 基础
Python入门 一.第一句Python 在 /home/dev/ 目录下创建 hello.py 文件,内容如下: print "hello,world" 执行 hello.py ...
- linux特殊权限位suid
特殊权限位基本说明(了解): linux系统基本权限位为9位权限,但还有额外3位权限位,共12位权限: suid s(x) S 4 用户对应的权限位(用户对应的3位 ...
- tcl之控制流-foreach
- L2-029 特立独行的幸福 (25 分)
L2-029 特立独行的幸福 (25 分) 对一个十进制数的各位数字做一次平方和,称作一次迭代.如果一个十进制数能通过若干次迭代得到 1,就称该数为幸福数.1 是一个幸福数.此外,例如 19 经过 ...
- django之python3.4及以上连接mysql的一些问题记录
首先,祭出大杀器whl https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient django1.x与django2.x 在项目的写法上有一些区别 ...
- 创建、导入、导出、复制以及粘贴 WMI 筛选器
TechNet 库 Deployment Forefront Identity and Access Management 基础结构优化 浏览器 Microsoft Dynamics Products ...
- centos 6.4安装杀毒软件clamAV 0.98[转]
原文出处: http://dnuser.blog.51cto.com/4863891/1303829 1.查看系统版本 [root@local]# lsb_release -a LSB Versi ...
- VSX-3 VSCT文件
关于VSPackage中的VSCT,算是VSX开发中比较重要的一个成员. 我这里给出LearnVSXNow!系列文章关于VSCT的链接,除了#14有译文. #14 #18 #25 看完上面几篇文章,也 ...
- 通过重写ViewGroup学习onMeasure()和onLayout()方法
在继承ViewGroup类时,需要重写两个方法,分别是onMeasure和onLayout. 1,在方法onMeasure中调用setMeasuredDimension方法 void android. ...
- USACO Section1.2 Palindromic Squares 解题报告
palsquare解题报告 —— icedream61 博客园(转载请注明出处)------------------------------------------------------------ ...