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和⑨两种 ...
随机推荐
- 编译安装 nginx php swoole
安装之前先 准备环境 yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel 然后 ...
- 在VMware上安装centos7
1. 下载centos7 64位镜像 linux官网下载:https://www.centos.org/download/ 2. 在VMware上安装centos7 2.1 新建虚拟机 打开虚拟机主页 ...
- LeetCode935
问题:935. 骑士拨号器 国际象棋中的骑士可以按下图所示进行移动: . 这一次,我们将 “骑士” 放在电话拨号盘的任意数字键(如上图所示)上,接下来,骑士将会跳 N-1 步. ...
- leetcode-13-basic-binaryTree
101. Symmetric Tree 解题思路: 递归的方法如下.分几种情况考虑,如果左子树和右子树都是空,那么返回true:如果不同时为空,返回false:如果都不为空,则 判断其值是否相等,不相 ...
- German Collegiate Programming Contest 2015
// Legacy Code #include <iostream> #include <cstdio> #include <cstring> #include & ...
- debian使用ibus
$ sudo apt-get install ibus ibus-pinyin 点击右上角的键盘图标,设置拼音输入法
- POJ - 1321 深度优先搜索入门
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> us ...
- 大数据学习——SparkStreaming整合Kafka完成网站点击流实时统计
1.安装并配置zk 2.安装并配置Kafka 3.启动zk 4.启动Kafka 5.创建topic [root@mini3 kafka]# bin/kafka-console-producer. -- ...
- Canvas链式操作
Canvas 链式操作 canvas有个非常麻烦的地方就是不支持链式操作,导致书写极其繁琐,刚刚学习了canvas的链式操作. 下面是代码 改进之后的写法,犀利得多啊! 1.canvas = ...
- set(集合)类
1.set(集合)和 map(映射) 都属于关联容器,它们都支持查询一个元素是否存在,并能有效地获取元素.实现了红黑树的平衡二叉检索树的数据结构,插入元素时,它会自动调整二叉树的排列,把元素放到适当的 ...