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. IOS AppStore介绍图的尺寸大小(还有一些自己被拒的分享...)

    4s:640*960 5:640*1136 6:750*1334 6P:1242*2208 -------现在新版本的iTunes connect里只上传6P版本的大小就可以了,其他版本苹果会自动分辨 ...

  2. tensorflow 线性回归 iris

    线性拟合

  3. 集训Day4

    在bzoj刷了好几天杂题感觉手感不是很好 继续回来集训一下 好几天没更新了啊... bzoj1875 一个无向图,一个人要从起始点走$t$步走到终点,不能沿着刚走过来那条边回去,问有多少种走法 $m ...

  4. 7th

    2017-2018-2 20179212<网络攻防技术>第7周作业 课本学习 Windows操作系统基本框架 1.windows基本结构分为运行于处理器特权模式的操作系统内核以及运行在处理 ...

  5. 【LeetCode】282. Expression Add Operators

    题目: Given a string that contains only digits 0-9 and a target value, return all possibilities to add ...

  6. 重学JAVA基础(二):Java反射

        看一下百度的解释:       JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息     ...

  7. Ubuntu下Apache重启错误:Could not reliably determine解决

    错误信息:apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 ...

  8. ubuntu14.04 设置默认使用root用户登录

    首先修改/etc/lightdm/lightdm.conf,设置autologin-user=root 但是此时直接重启,会报如下的错误: 解决办法: 使用命令: vim /root/.profile ...

  9. 系统启动挂载根文件系统时Kernel panic

    转自:http://qiuye.iteye.com/blog/543595 这类问题很常见,先总体介绍一下解决思路. 能出现让人激动的的控制台,那么系统移植已经接近完成:但是不少人在最后一步出现问题. ...

  10. string行读入&&文件输入

    普通读入的时候会以空格作为分隔符 直接用cin>>s读入,此时可以直接处理文件尾的情况 text代码: #include <iostream>#include <cstd ...