当前位置:网站首页>【BZOJ2393】Cirno的完美算数教室
【BZOJ2393】Cirno的完美算数教室
2022-07-19 11:47:00 【LauJiYeoung】
~Cirno发现了一种baka数,这种数呢~只含有2和⑨两种数字~~
现在Cirno想知道~一个区间中~~有多少个数能被baka数整除~
但是Cirno这么天才的妖精才不屑去数啦
只能依靠聪明的你咯
弱化版的SCOI2010幸运数字
还是考虑值的增长率很快所以暴力容斥就好了
#include<bits/stdc++.h>
using namespace std;
typedef int INT;
#define int long long
int L,R;
int Baka[3000];
int vis[3000];
int A[3000];
int cnt=0;
void DFS(int x,int sum){
if(sum>R)return;
if(sum)Baka[++cnt]=sum;
DFS(x+1,sum*10+2);
DFS(x+1,sum*10+9);
}
int ans=0;
int GCD(int x,int y){
while(y){
int tmp=y;
y=x%y;
x=tmp;
}
return x;
}
void Solve(int x,int sum,int flag){
if(sum<0||sum>R)return;
if(x==A[0]+1){
if(!sum)return;
ans=(ans+(R/sum-L/sum)*flag);
return;
}
int tmp;
if(!sum)tmp=A[x];
else tmp=sum/GCD(A[x],sum)*A[x];
Solve(x+1,tmp,flag*-1);
Solve(x+1,sum,flag);
}
bool cmp(int A,int B){
return A>B;
}
signed main(){
cin>>L>>R;
L--;
DFS(1,0);
sort(Baka+1,Baka+1+cnt);
for(int i=1;i<=cnt;++i){
if(!vis[i])A[++A[0]]=Baka[i];
for(int j=i+1;j<=cnt;++j){
if(Baka[j]%Baka[i]==0)vis[j]=1;
}
}
sort(A+1,A+1+A[0],cmp);
Solve(1,0,-1);
cout<<ans;
}
边栏推荐
- 论文翻译解读:PARIS :Probabilistic Alignment of Relations, Instances, and Schema
- 面试官必问的 3 道 MQ 面试题,还有谁不会??
- 基于Xlinx的时序分析与约束(1)----什么是时序分析?什么是时序约束?什么又是时序收敛?
- 云原生指南:什么是云原生基础架构
- (0711-0717) memorabilia of open source software security this week
- Innovation and survival of scholars, step by step
- Cooperatively Coevolving Particle Swarms forLarge Scale Optimization
- 线程池,我是谁?我在哪儿?
- What is a honeypot
- Vulnhub | DC: 6 |【实战】
猜你喜欢
NetApp 扩展柜 Disk Shelf 扩容方法步骤
Vulnhub | DC: 6 |【实战】
Cloud Native Core Technology: Service Mesh Implementation - istio
Cooperatively Coevolving Particle Swarms forLarge Scale Optimization
Socket error Event: 32 Error: 10053. Connection closing...Socket close
【单片机】51单片机烧录那些事儿
二维码智能巡检系统让电站设备巡检更智能
【MATLAB】基于油猴脚本和MATLAB下载原创力文档
CBC 模式和 ECB 模式解读
JSD-2204-微博项目(完结)-Day16
随机推荐
mouseenter 与 mouseover 的区别
QR code intelligent inspection system makes the inspection of power station equipment more intelligent
Ask a question: scenario: the cumulative window is used in Flink SQL. The window size is one day, and the cumulative of the current day is counted every minute
剑指offer题库总结(二)之字符串(C语言版本)
2022.7.10-----leetcode. seven hundred and forty-one
Silvaco二极管、三极管、CMOS的制备
揭秘MAE的数据增强潜力,上交&华为基于MAE提出掩蔽重建数据增强
mos管的输入输出特性曲线及gm/id仿真曲线(cadence IC617)
【历史上的今天】7 月 13 日:数据库之父逝世;苹果公司购买 CUPS 代码;IBM 芯片联盟
TCP/IP四层模型中的重点网络协议
With arbitrary pricing, products difficult to distinguish between true and false, and platforms running away, will the digital Tibet market continue to be popular?
Import word document pictures kernel synchronization and mutual exclusion
Eolink 和 JMeter 接口测试对比
Use masonry to realize width adaptation and height adaptation of controls (including uitableview) according to content
股票开户首选,炒股交易开户佣金最低手机上开户安不安全
Week 5 Image Classification、Bag of Visual Words (Bag of Features) and Multi-Layer Neural Networks
南方CASS 10.1软件安装包下载及安装教程
Paris:probabilistic alignment of relations, instances, and schema
Was expecting double quote to start field name error
DevOps 实践多年,最痛的居然是?