博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces 483B Friends and Presents
阅读量:4286 次
发布时间:2019-05-27

本文共 1023 字,大约阅读时间需要 3 分钟。

     

/********************************************************************************* 题意:一个人有两个 friends,需要将 a个不能整除 x 的数分给第一个friend,****        b 个不能整除 y 的数分给第二个friend。x 和 y 都是素数来的。****        要求求出最小的 w,w表示可以从1,2,...,w 中取数。**** 题解:二分查找【1,1e18】*****************************************************************************/#include
#include
#include
#include
#include
using namespace std;typedef long long LL;LL x,y,a,b;bool check(LL w){ LL x1 = w / x; LL x2 = w / y; LL B = w /(x * y); LL A = x1 - B; LL C = x2 - B; LL shengyu = w - A - B - C; LL a1 , b1; if(a > C) a1 = a - C; else a1 = 0; if(b > A) b1 = b - A; else b1 = 0;// cout << shengyu << endl; if(shengyu >= a1 + b1) return true; return false;}int main(){ cin >> a >> b >> x >> y; LL l = 1,r = 1e18;// cout << r << endl; LL mid; while(l < r){ mid = (l + r ) / 2; if(check(mid)) r = mid; else l = mid + 1; } cout << r << endl;}

你可能感兴趣的文章
小程序Canvas隐藏问题处理
查看>>
小程序scroll-view组件使用简介(转)
查看>>
Visual Studio Code设置中文包/配置中文语言
查看>>
Git重置登录密码问题,Git-remote Incorrect username or password ( access token )
查看>>
C#时间点字符串转换为日期,当天时间点判断
查看>>
Visual Studio Code v1.28.2发布
查看>>
js计算时间差示例
查看>>
VSCode中Vue插件使用整理
查看>>
Cordova 生成慢问题,卡在Gradle:Download https://services.gradle.org/
查看>>
谷歌浏览器如何隐藏控制台的警告内容打印console.warn()
查看>>
JavaScript数据类型
查看>>
JavaScript内置对象
查看>>
VSCode 开发Cordova应用调试整理
查看>>
VSCode修改插件的安装启动位置
查看>>
ueditor编辑器asp.net版本任意上传漏洞处理
查看>>
C#如何获取今天零点的时间
查看>>
EF 根据绝对值排序处理
查看>>
asp.net 跨子域名域Session丢失问题
查看>>
jquery.cookie.js 使用整理(一)
查看>>
Jquery.cookie使用实例1
查看>>