codeforces 483B. Friends and Presents
来源:互联网 发布:旋转轮胎怎么修改数据 编辑:程序博客网 时间:2024/05/16 04:16
点击打开链接
题目意思:有两个 friends,需要将 cnt1 个不能整除 x 的数分给第一个friend,cnt2 个不能整除 y 的数分给第二个friend。x 和 y 都是素数来的。要求求出最小的 v,v 表示可以从1,2,...,v 中取数
点击打开链接
//15 ms 0 KB#include<stdio.h>#include<algorithm>#define ll long longusing namespace std;ll n,m,x,y;bool check(ll mid){ ll num1=mid/x; ll num2=mid/y; ll both=mid/(x*y); ll count=mid-num1-num2+both; ll cnt1=num1-both; ll cnt2=num2-both; ll res1=max(m-cnt1,(ll)(0)); ll res2=max(n-cnt2,(ll)(0)); return (res1+res2<=count);}int main(){ while(scanf("%lld%lld%lld%lld",&n,&m,&x,&y)!=EOF) { ll l=1,r=1e10,mid; while(l<r) { mid=(l+r)>>1; if(check(mid))r=mid; else l=mid+1; } printf("%lld\n",r); } return 0;}
0 0
- codeforces 483b Friends and Presents 二分
- codeforces 483B Friends and Presents
- CodeForces - 483B Friends and Presents
- codeforces 483B. Friends and Presents
- CodeForces-483B Friends and Presents(二分)
- 【CODEFORCES】 B. Friends and Presents
- Codeforces 483B - Friends and Presents(二分)
- Codeforces 483B Friends and Presents(二分+数论)
- Codeforces 483B. Friends and Presents 二分查找
- Review of codeforces 483B Friends and Presents
- codeforces #483B# Friends and Presents(二分+math)
- Codeforces 483B Friends and Presents【二分+数论】涨姿势~~~
- B. Friends and Presents
- Codeforces Round #275 (Div. 2) B Friends and Presents
- B. Friends and Presents(Codeforces Round #275(div2)
- B. Friends and Presents(Codeforces Round #275(div2)
- Codeforces Round #275 (Div. 2) --B Friends and Presents
- Codeforces Round #275 (Div. 2) --B Friends and Presents
- 关于那些Android中不常用的设置属性
- hdu 1394 Minimum Inversion Number(树状数组)
- Linux内核的时钟中断(4)
- activity的四种启动方式
- Linux 命令神器:lsof 入门
- codeforces 483B. Friends and Presents
- St=Sw+Sb
- Unity3D研究院之代码使用IK动画(五十五)
- 6个Java项目UML反向工程工具
- Android DEX格式中try, catch的处理
- 【问题解决】无法创建新的堆栈防护页面
- html img Src base64 图片显示
- [ASP.NET-IV] SQL Server 08创建数据库 创建表II(使用约束)
- iOS socket编程