当前位置:网站首页>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;
}
边栏推荐
- Leetcode (417) -- Pacific Atlantic current problem
- Design, configuration and points for attention of network specified source multicast (SSM) simulation using OPNET
- 背包问题(01背包,完全背包,动态规划)
- LinkedBlockingQueue源码分析-初始化
- Leetcode (46) - Full Permutation
- [QT] custom control loading
- Disk monitoring related commands
- 最长不下降子序列(LIS)(动态规划)
- JHOK-ZBL1漏电继电器
- Most commonly used high number formula
猜你喜欢
10 distributed databases that take you to the galaxy
Photo selector collectionview
在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
Use Zhiyun reader to translate statistical genetics books
阿里云的神龙架构是怎么工作的 | 科普图解
JVM (19) -- bytecode and class loading (4) -- talk about class loader again
JVM(十九) -- 字节码与类的加载(四) -- 再谈类的加载器
JVM (XX) -- performance monitoring and tuning (I) -- Overview
高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
一条 update 语句的生命经历
随机推荐
Dbsync adds support for mongodb and ES
Use Zhiyun reader to translate statistical genetics books
项目经理如何凭借NPDP证书逆袭?看这里
SQL injection - secondary injection and multi statement injection
Complete code of C language neural network and its meaning
Annotation初体验
磁盘监控相关命令
DOM node object + time node comprehensive case
Is the human body sensor easy to use? How to use it? Which do you buy between aqara green rice and Xiaomi
[PHP SPL notes]
照片选择器CollectionView
JHOK-ZBL1漏电继电器
What changes will PMP certification bring?
LabVIEW is opening a new reference, indicating that the memory is full
做自媒体,有哪些免费下载视频剪辑素材的网站?
SQL injection cookie injection
Aidl and service
漏电继电器LLJ-100FS
app clear data源码追踪
高压漏电继电器BLD-20