专栏文章
题解:CF2044E Insane Problem
CF2044E题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mipuok5t
- 此快照首次捕获于
- 2025/12/03 18:14 3 个月前
- 此快照最后确认于
- 2025/12/03 18:14 3 个月前
题解:CF2044E Insane Problem
分析
我们先将 转化为 。
题目说了 ,也就是说 。那么我们算一下, 当 取 时, 最大约为 。我们可以枚举 ,算出当前 的取值区间以及 的取值区间,再将两个区间的交集累加入答案中。
代码
CPP#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int t;
cin>>t;
while(t--){
int k,l1,r1,l2,r2,sum=0,asd=1;
cin>>k>>l1>>r1>>l2>>r2;
for(int i=0;r2/asd>=l1;i++){
int num=max(0,min(r1,r2/asd)-max(l1,(l2-1)/asd+1)+1);
asd*=k,sum+=num;
}
cout<<sum<<"\n";
}
return 0;
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...