当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

MySQL的优化分析及效率执行

自动化测试框架该如何搭建?

How does win11 change the power mode? Win11 method of changing power mode

The auxiliary role of rational cognitive educational robot in teaching and entertainment

MySQL - multi table query - Cartesian product sum, correct multi table query, equivalent connection and unequal connection, inner connection and outer connection

Spark Structured Streaming HelloWorld

1. Mx6u system migration-6-uboot graphical configuration

ASP. Net core actionfilter filter details

Matlab drawing

UE4 键盘控制开关灯
随机推荐
1、 Basic introduction
What if win11 cannot wake up from sleep? Solution of win11 unable to wake up during sleep
makefile知识再整理(超详细)
Credit card fraud detection based on machine learning
MapReduce中分区数与ReduceTask个数关系比较
Postman 导入curl 、导出成curl、导出成对应语言代码
idea插件离线安装(持续更新)
Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release
Day26 job
Spark Structured Streaming HelloWorld
How is the launch of ros2 different?
七、RESTful
RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程
2022河南萌新联赛第(三)场:河南大学 L - 合成游戏
Sweet butter
Ffmpeg video coding
Array sort 1
Makefile knowledge rearrangement (super detailed)
[C language foundation] 13 preprocessor
Matlab drawing