AC日记——[SCOI2010]幸运数字 bzoj 1853
1853: [Scoi2010]幸运数字
Time Limit: 2 Sec Memory Limit: 64 MB
Submit: 2405 Solved: 887
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
1 10
【样例输入2】
1234 4321
Sample Output
2
【样例输出2】
809
HINT
【数据范围】
对于30%的数据,保证1 < =a < =b < =1000000
对于100%的数据,保证1 < =a < =b < =10000000000
Source
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; long long int l,r,table[],num,ans; void pdfs(long long int now)
{
if(now>r) return ;
table[++num]=now;
pdfs(now*+),pdfs(now*+);
} void pre()
{
pdfs(),pdfs();
sort(table+,table+num+);
long long new_table[],new_num=;
for(int i=;i<=num;i++)
{
for(int j=;j<i;j++)
{
if(table[j]==) continue;
if(table[i]%table[j]==)
{
table[i]=;
break;
}
}
if(table[i]) new_table[++new_num]=table[i];
}
num=new_num;
for(int i=;i<=num;i++) table[num-i+]=new_table[i];
return ;
} inline long long int gcd(long long int x,long long int y)
{
return y?gcd(y,x%y):x;
} void dfs(long long int now,int p,bool lev)
{
if(now>r) return ;
if(lev) ans+=r/now,ans-=l/now;
else ans-=r/now,ans+=l/now;
for(int i=p;i<=num;i++)
{
double pos=now/gcd(now,table[i]);
if(pos<=r/table[i]) dfs(pos*table[i],i+,lev^);
}
} int main()
{
freopen("luckynumber.in","r",stdin);
freopen("luckynumber.out","w",stdout);
cin>>l>>r;
pre(),l--;
for(int i=;i<=num;i++) dfs(table[i],i+,true);
cout<<ans;
fclose(stdin),fclose(stdout);
return ;
}
AC日记——[SCOI2010]幸运数字 bzoj 1853的更多相关文章
- 幸运数字(bzoj 1853)
Description 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的“幸运号码”是十进制表示中只包含数字6和8的那些号码,比如68,666,888都是“幸运号码”! ...
- AC日记——[Scoi2010]序列操作 bzoj 1858
1858 思路: 恶心: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 struct Tree ...
- BZOJ 1853: [Scoi2010]幸运数字
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2117 Solved: 779[Submit][Status] ...
- Bzoj 1853: [Scoi2010]幸运数字 容斥原理,深搜
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 1774 Solved: 644[Submit][Status] ...
- bzoj 1853: [Scoi2010]幸运数字 容斥
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 1170 Solved: 406[Submit][Status] ...
- 【BZOJ 1853】 1853: [Scoi2010]幸运数字 (容斥原理)
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2472 Solved: 911 Description 在中国 ...
- 1853: [Scoi2010]幸运数字[容斥原理]
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2405 Solved: 887[Submit][Status] ...
- bzoj1853[Scoi2010]幸运数字 容斥
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 3027 Solved: 1128[Submit][Status ...
- BZOJ_2393_Cirno的完美算数教室&&BZOJ_1853_[Scoi2010]幸运数字 _深搜+容斥原理
BZOJ_2393_Cirno的完美算数教室&&BZOJ_1853_[Scoi2010]幸运数字 _深搜+容斥原理 题意: ~Cirno发现了一种baka数,这种数呢~只含有2和⑨两种 ...
随机推荐
- logback写日志
https://blog.csdn.net/u010128608/article/details/76618263 https://blog.csdn.net/zhuyucheng123/articl ...
- spring IOC注解与xml配置
转载自:https://blog.csdn.net/u014292162/article/details/52277756 IOC 1小案例 将对象的依赖交给配置文件来配置(配置文件的名字是可以任意的 ...
- Laravel核心解读--Console内核
Console内核 上一篇文章我们介绍了Laravel的HTTP内核,详细概述了网络请求从进入应用到应用处理完请求返回HTTP响应整个生命周期中HTTP内核是如何调动Laravel各个核心组件来完成任 ...
- tp5使用外部类的三种方法
在tp5中使用外部类的时候有三种方法 第一种就是通过composer下载,通过这种方式下载的外部类能够支持自动加载,我们只要在使用的时候use一下命名空间就可以使用了 比如:我们的tp5第四季项目要使 ...
- python向上取整 向下取整
向上取整 ceil() 函数返回数字的向上取整整数,就是返回大于等于变量的最近的整数. ceil()是不能直接访问的,需要导入 math 模块. import math math.ceil( x ) ...
- MySQL配置允许远程登录
MySQL默认只允许用户本地登录,需要远程连接可进行如下操作: 允许root用户在任何地方进行远程登录,并具有所有库任何操作权限: 使用root用户登录mysql: mysql -u root -p& ...
- Linux学习-检验软件正确性
md5sum / sha1sum / sha256sum 目前有多种机制可以计算文件的指纹码,我们选择使用较为广泛的 MD5, SHA1 或 SHA256 加密机 制来处理,我们拿NTP 软件来检查看 ...
- HDU 5489 Removed Interval DP 树状数组
题意: 给一个长度为\(N\)的序列,要删除一段长为\(L\)的连续子序列,问所能得到的最长的\(LIS\)的长度. 分析: 设\(f(i)\)表示以\(a_i\)结尾的\(LIS\)的长度,设\(g ...
- CodeForces 14D 树的直径 Two Paths
给出一棵树,找出两条不相交即没有公共点的路径,使得两个路径的长度的乘积最大. 思路:枚举树中的边,将该边去掉,分成两棵树,分别求出这两棵树的直径,乘起来维护一个最大值即可. #include < ...
- luogu2473 [SCOI2008]奖励关
题解参照这里 每个研究完记得乘一个1/n,这是乘了概率. #include <iostream> #include <cstdio> using namespace std; ...