当前位置:网站首页>Educational Codeforces Round 22 B. The Golden Age
Educational Codeforces Round 22 B. The Golden Age
2022-07-06 23:36:00 【不吃土司边】
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
#define int long long
const int N = 1e5+2;
const int INF = 1<<30;
const int mod = 1e9+7;
int x,y,L,R;
std::vector<int> v;
map<int,int> mp;
void solve(){
scanf("%lld%lld%lld%lld",&x,&y,&L,&R);
for(int i=1;i<=R;i=i*x){
for(int j=1;j+i<=R;j=j*y){
if(i+j>=L&&i+j<=R&&mp.count(i+j)==0){
v.push_back(i+j);
mp[i+j]=1;
}
// cout<<i<<" "<<j<<" "<<(R-i)/j<<" "<<y<<endl;
if((R-i)/j<y) break;
}
if(R/i<x) break;
}
v.push_back(R+1);
sort(v.begin(),v.end());
int st=L-1,ans=0;
for(int i=0;i<v.size();i++){
if(ans<v[i]-st-1){
ans=v[i]-st-1;
}
st=v[i];
}
cout<<ans<<endl;
return;
}
int32_t main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- [optimal web page width and its implementation] [recommended collection "
- Addressable pre Download
- Design, configuration and points for attention of network arbitrary source multicast (ASM) simulation using OPNET
- 【QT】自定义控件-Loading
- How can project managers counter attack with NPDP certificates? Look here
- Auto. JS get all app names of mobile phones
- Operand of null-aware operation ‘!‘ has type ‘SchedulerBinding‘ which excludes null.
- JHOK-ZBL1漏电继电器
- y58.第三章 Kubernetes从入门到精通 -- 持续集成与部署(三一)
- 照片选择器CollectionView
猜你喜欢
【js组件】自定义select
《5》 Table
全链路压测:影子库与影子表之争
[opencv] image morphological operation opencv marks the positions of different connected domains
pytest测试框架——数据驱动
利用OPNET进行网络单播(一服务器多客户端)仿真的设计、配置及注意点
AOSP ~binder communication principle (I) - Overview
How Alibaba cloud's DPCA architecture works | popular science diagram
JVM(二十) -- 性能监控与调优(一) -- 概述
10 distributed databases that take you to the galaxy
随机推荐
Two methods of thread synchronization
LinkedBlockingQueue源码分析-初始化
Two person game based on bevy game engine and FPGA
Pytest testing framework -- data driven
Where is NPDP product manager certification sacred?
K6el-100 leakage relay
Egr-20uscm ground fault relay
MySQL数据库学习(7) -- pymysql简单介绍
漏电继电器JOLX-GS62零序孔径Φ100
2039: [蓝桥杯2022初赛] 李白打酒加强版 (动态规划)
[question] Compilation Principle
说一说MVCC多版本并发控制器?
在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
A cool "ghost" console tool
最长公共子序列(LCS)(动态规划,递归)
window定时计划任务
做自媒体,有哪些免费下载视频剪辑素材的网站?
与利润无关的背包问题(深度优先搜索)
How can project managers counter attack with NPDP certificates? Look here
线程同步的两个方法