51nod1222

http://210.33.19.103/contest/1113/problem/2

同学的神仙做法:

首先考虑先去掉X<=Y的限制,也就是先计算满足要求的任意有序pair(X,Y)的数量,再用一些简单操作(略去)得到目标答案

化简式子可以得到$\sum_{d}\mu(d)\sum_a\sum_b\sum_c[abc<={\lfloor}\frac{n}{d^2}{\rfloor}]$

可以强行给a,b,c规定一个顺序。设a是最小的,则a只需要枚举到$(\frac{n}{d^2})^{1/3}$就行

剩下有很多做法了,略去了

 %:pragma GCC optimize()
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
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;
int mu[];
int prime[],len;
bool nprime[];
/*
ll calc0(ll n)
{
ll d,i,j,k,tan1,tan2,tan3,t1;
for(d=1;;++d)
{
if(d*d>n) break;
t1=n/(d*d);
tan1=tan2=tan3=0;
for(i=1;i<=100;++i)
for(j=1;j<=100;++j)
for(k=1;k<=100;++k)
if(i*j*k<=t1)
if(i==j&&j==k)
++tan3;
else if(i==j||j==k||i==k)
++tan2;
else ++tan1;
printf("at%lld %lld %lld\n",tan1,tan2,tan3);
}
return 233;
}
*/
ll calc(ll n)
{
ll d,t1,t2,endj,i,j,j1,tan1,tan2,tan3,ans=,endi;
for(d=;;++d)
if(mu[d])
{
if(d*d>n) break;
t1=n/(d*d);
tan1=tan2=tan3=;
for(i=;;++i)
{
if(i*i*i>t1) break;
t2=t1/i;
endj=ll(sqrt(t2+0.5));
for(j=i+;j<=endj;j=j1+)
{
j1=min(endj,t2/(t2/j));
tan1+=(t2/j)*(j1-j+);
}
if(i+<=endj)
tan1-=(endj+i+)*(endj-i)/;
}
tan1*=;
endi=ll(sqrt(t1+0.5));
for(i=;i<=endi;++i)
tan2+=t1/(i*i);
for(i=;;++i)
{
if(i*i*i>t1) break;
++tan3;
}
tan2=(tan2-tan3)*;
ans+=mu[d]*(tan1+tan2+tan3);
//printf("1t%lld %lld %lld %lld\n",d,tan1,tan2,tan3);
}
return ans;
}
int main()
{
ll i,j,t;
mu[]=;
for(i=;i<=;i++)
{
if(!nprime[i]) prime[++len]=i,mu[i]=-;
for(j=;j<=len&&(t=i*prime[j])<=;j++)
{
nprime[t]=;
if(i%prime[j]==) {mu[t]=;break;}
else mu[t]=-mu[i];
}
}
ll a,b;
scanf("%lld%lld",&a,&b);
printf("%lld\n",(calc(b)-calc(a-)+b-a+)/);
//calc0(b);calc0(a-1);
return ;
}

51nod1222最小公倍数计数的更多相关文章

  1. 51nod1222 最小公倍数计数

    题目来源: Project Euler 基准时间限制:6 秒 空间限制:131072 KB 分值: 640  定义F(n)表示最小公倍数为n的二元组的数量. 即:如果存在两个数(二元组)X,Y(X & ...

  2. 51Nod1222 最小公倍数计数 数论 Min_25 筛

    原文链接https://www.cnblogs.com/zhouzhendong/p/51Nod1222.html 题意 给定 $a,b$, 求 $$\sum_{n=a}^b \sum_{i=1}^n ...

  3. 51nod1222 最小公倍数计数 莫比乌斯反演 数学

    求$\sum_{i = 1}^{n} \sum_{j = 1}^{i} [lcm(i, j) \le n]$因为这样不好求,我们改成求$\sum_{i = 1}^{n} \sum_{j = 1}^{n ...

  4. [51nod1222] 最小公倍数计数(莫比乌斯反演)

    题面 传送门 题解 我此生可能注定要和反演过不去了--死都看不出来为啥它会突然繁衍反演起来啊-- 设\(f(n)=\sum_{i=1}^n\sum_{j=1}^n[{ij\over\gcd(i,j)} ...

  5. 【51nod】1222 最小公倍数计数 莫比乌斯反演+组合计数

    [题意]给定a和b,求满足a<=lcm(x,y)<=b && x<y的数对(x,y)个数.a,b<=10^11. [算法]莫比乌斯反演+组合计数 [题解]★具体 ...

  6. 51NOD 1222 最小公倍数计数 [莫比乌斯反演 杜教筛]

    1222 最小公倍数计数 题意:求有多少数对\((a,b):a<b\)满足\(lcm(a,b) \in [1, n]\) \(n \le 10^{11}\) 卡内存! 枚举\(gcd, \fra ...

  7. [51Nod 1222] - 最小公倍数计数 (..怎么说 枚举题?)

    题面 求∑k=ab∑i=1k∑j=1i[lcm(i,j)==k]\large\sum_{k=a}^b\sum_{i=1}^k\sum_{j=1}^i[lcm(i,j)==k]k=a∑b​i=1∑k​j ...

  8. 【51Nod 1222】最小公倍数计数

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1222 求\([a,b]\)中的个数转化为求\([1,b]\)中的个数减去 ...

  9. 51nod 1222 最小公倍数计数【莫比乌斯反演】

    参考:https://www.cnblogs.com/SilverNebula/p/7045199.html 所是反演其实反演作用不大,又是一道做起来感觉诡异的题 转成前缀和相减的形式 \[ \sum ...

随机推荐

  1. java 基础 - 查找某个字串出现的次数及位置

    查找某个字串出现的次数及位置 public class search { public static void main(String[] args){ String str = "abc1 ...

  2. 机器学习:Selective Search for Object Recognition

    今天介绍 IJCV 2013 年的一篇文章,Selective Search for Object Recognition,这个是后面著名的DL架构 R-CNN 的基础,后续介绍 R-CNN 的时候, ...

  3. Mac使用记录

    ---恢复内容开始--- brew list //查看brew安装东东 ls //当前目录下内容 brew --cache //查看brew下载目录 /usr/local/Cellar/ //隐藏文件 ...

  4. 【Lintcode】122.Largest Rectangle in Histogram

    题目: Given n non-negative integers representing the histogram's bar height where the width of each ba ...

  5. 使用msiexec提取msi包里的文件

    核心:如需把d盘下abc.msi文件解包到目录d:\abc,操作如下:打开命令提示符,输入msiexec /a "d:\abc.msi" /qb TARGETDIR="D ...

  6. 洛谷P3373线段树模板2

    题目:https://www.luogu.org/problemnew/show/P3373 带乘的线段树,更新时把加的标记也乘一下,然后取值时先乘后加. 代码如下: #include<iost ...

  7. 数据库关键字 (Oracle, SQL Server, DB2)

    Oracle SQL Server DB2 ! @@IDENTITY   DETERMINISTIC & ADD   DISALLOW      ( ALL   DISCONNECT    ) ...

  8. struts2的使用知识点

    最开始学习java的时候学习过struts,但是对配置和struts的理解深度不够,现在工作虽然再用,但是自己搭建环境和使用心得始终很零散,所以现在决定重新理一遍,有条理的学习一下struts. 至于 ...

  9. Python之常用模块(一)

      time & datatime 模块 random os sys shutil json & picle   time & datetime 时间戳(1970年1月1日之后 ...

  10. simple demo of Handlebars.js & jquery.js

    simple demo of Handlebars.js & jquery.js <html> <head> <script src="jquery-1 ...