当前位置:网站首页>2022 Henan Mengxin League game (3): Henan University a - corn cannon
2022 Henan Mengxin League game (3): Henan University a - corn cannon
2022-07-26 04:31:00 【WA_ automata】
A - Cob Cannon
It is easy to find that the answer is monotonous , If it costs x Time can defeat the target , It costs x + 1 x + 1 x+1 Time can also defeat the target , You can directly split the answer , Considering that the left and right range of two points is [ 0 , 1 0 18 ] [0, 10^{18}] [0,1018], about C + + Contestants may need to use __int128 , Or judge in advance whether it is legal in the process of dichotomy .
- Time complexity O ( n × l o g ( 1 0 18 ) ) O(n × log(10^{18})) O(n×log(1018))
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
int a[N],b[N];
int n,m;
int check(LL x)
{
LL sum=0;
for(int i=1;i<=n;i++)
{
sum+=(x/b[i]+1)*a[i];
if(sum>=m) return 1;
}
return 0;
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
LL l=0,r=1e18;
while(l<r)
{
LL mid=(l+r)>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<r<<endl;
return 0;
}
边栏推荐
猜你喜欢
随机推荐
远坂凛壁纸
egg-sequelize JS编写
Tutorial on using the one click upgrade function of the rtsp/onvif protocol video platform easynvr service
How to make your language academic when writing a thesis? Just remember four sentences!
这种是我的vs没连上数据库吗
I.MX6U-系统移植-6-uboot图形化配置
makefile知识再整理(超详细)
机器学习之桑基图(用于用户行为分析)
VM virtual machine has no un bridged host network adapter, unable to restore the default configuration
机器学习之信用卡欺诈检测
Steam science education endows classroom teaching with creativity
ASP. Net core actionfilter filter details
autocomplete禁止表单自动填充
10、 Interceptor
Scroll view pull-down refresh and pull-up load (bottom)
Solution: runtimeerror: expected object of scalar type int but got scalar type double
RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程
UE4 two ways to obtain player control
Graph translation model
[uoj 429] runs (inclusive) + a little record about Lyndon tree and its application







