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和⑨两种 ...
随机推荐
- spring boot yaml 自定义配置 映射到 java POJO
只需要一个注解就ok: @ConfigurationProperties("user.other") “user.other” 这个值匹配的是user下的other对象 yaml ...
- destoon 多表联合查询时出现解析错误,parse_str函数解析错误
数据库前缀 wb_ 标签 ,调用文章时获取评论数量 <!--{php $tags=tag("table=article_24 a left join wb_comment_stat ...
- Ubuntu 16.04中安装谷歌Chrome浏览器
1.进入 Ubuntu 16.04 桌面,按下 Ctrl + Alt + t 键盘组合键,启动终端. 2.在终端中,输入以下命令: sudo wget https://repo.fdzh.org/ch ...
- python hashlib模块学习
目录 hashlib 模块 破解密码 hmac 模块 hashlib 模块 1.干嘛用的: 对字符进行加密,其实就是一个自定义的字符编码表,我们原来接触的是计算机语言0和1然后转化成字符,而hashl ...
- 08/07/2017 R
from today,i will learn something about the R. install R studio code: 1.>install.packages("s ...
- Linux学习-灾难复原的考虑
硬件损毁,且具有完整备份的数据时 由于是硬件损毁,所以我们不需要考虑系统软件的不稳定问题,所以可以直接将完整的系统复原回去 即可. 由于软件的问题产生的被攻破资安事件 由于系统的损毁是因为被攻击,此时 ...
- TSS (任务状态段)的作用及结构
1.什么是TSS TSS全称Task State Segment ,是操作系统在进行进程切换时保存进程现场信息的段 2.TSS什么时候用,有什么用 TSS在任务(进程)切换时起着重要的作用,通过它保存 ...
- Vue简单了解
目录 1. 前端概览 2. 现代前端开发方式 3. MVVM开发核心 4. Vue核心 5. Vue优点 6. Vue难点 7. Vue与非Vue项目结合 8. Vue调试 9. Vue与SEO 今天 ...
- 简单配置.htaccess就可以实现的10个功能
http://bbs.itcast.cn/thread-25990-1-1.html?xhw 1. 反盗链那些盗用了你的内容,还不愿意自己存储图片的网站是很常见的.你可以通过以下配置来放置别人盗用你的 ...
- Selenium WebDriver-获取与切换浏览器窗口的句柄
通过selenium webdriver去切换浏览器的窗口,需要通过句柄,具体代码如下: #encoding=utf-8 import unittest import time import char ...