国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專(zhuān)題視頻專(zhuān)題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專(zhuān)題1關(guān)鍵字專(zhuān)題50關(guān)鍵字專(zhuān)題500關(guān)鍵字專(zhuān)題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專(zhuān)題關(guān)鍵字專(zhuān)題tag2tag3文章專(zhuān)題文章專(zhuān)題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專(zhuān)題3
問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

CodeforcesRound#275(Div.2)BFriendsandPresents_html/css

來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 15:57:01
文檔

CodeforcesRound#275(Div.2)BFriendsandPresents_html/css

CodeforcesRound#275(Div.2)BFriendsandPresents_html/css_WEB-ITnose:題目鏈接:Friends and Presents Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outpu
推薦度:
導(dǎo)讀CodeforcesRound#275(Div.2)BFriendsandPresents_html/css_WEB-ITnose:題目鏈接:Friends and Presents Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outpu

題目鏈接:Friends and Presents



Friends and Presents

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend andcnt2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.

In addition, the first friend does not like the numbers that are divisible without remainder by prime number x. The second one does not like the numbers that are divisible without remainder by prime number y. Of course, you're not going to present your friends numbers they don't like.

Your task is to find such minimum number v, that you can form presents using numbers from a set 1,?2,?...,?v. Of course you may choose not to present some numbers at all.

A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.

Input

The only line contains four positive integers cnt1, cnt2, x, y (1?≤?cnt1,?cnt2?

Output

Print a single integer ? the answer to the problem.

Sample test(s)

input

3 1 2 3

output

input

1 3 2 3

output

Note

In the first sample you give the set of numbers {1,?3,?5} to the first friend and the set of numbers {2} to the second friend. Note that if you give set {1,?3,?5} to the first friend, then we cannot give any of the numbers 1, 3, 5 to the second friend.

In the second sample you give the set of numbers {3} to the first friend, and the set of numbers {1,?2,?4} to the second friend. Thus, the answer to the problem is 4.





大致題意:A有兩個(gè)朋友B和C,B和C都很喜歡數(shù)字,現(xiàn)在A要送給他們各自一些不同的數(shù)字來(lái)做禮物,但是B不喜歡素?cái)?shù)x,所以不能送給他x的倍數(shù);同樣如此,C不喜歡素?cái)?shù)y,也不能送給他y的倍數(shù)?,F(xiàn)在的任務(wù)是從找到一個(gè)最小的數(shù)v,使得從1~v里面可以滿足A的要求,分別送給B和C。



解題思路:最開(kāi)始寫(xiě)的時(shí)候,用的是暴力枚舉,但是結(jié)果老是在一個(gè)樣例上錯(cuò),可能我的想法不對(duì)吧,得不到正確答案。后來(lái)看給出的官方解法是用二分。。想了半天,也沒(méi)想太明白,關(guān)鍵是想不好怎么用二分呀,該對(duì)誰(shuí)二分,寫(xiě)了這題,又漲姿勢(shì)了,原來(lái)可以從1到無(wú)窮大二分,感覺(jué)好神奇呀。二分,就要找好二分區(qū)間時(shí)的條件,根據(jù)題目要求,又想了想,才艱難的把這題給搞了。。



AC代碼:

#include #include using namespace std;int main(){//	freopen("in.txt", "r", stdin);	int n, m, x, y;	while(scanf("%d%d%d%d", &n, &m, &x, &y) == 4){	int l = 1, r = 2e9; //枚舉區(qū)間端點(diǎn)	while(l < r){ //二分	int mid = l + (r - l)/2;	if( n <= (mid - mid/x) && m <= (mid - mid/y) && n+m <= mid - mid/(x*y)) //劃分區(qū)間的條件	r = mid;	else	 	l = mid + 1;	}	printf("%d\n", r);	}	return 0;}

聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

CodeforcesRound#275(Div.2)BFriendsandPresents_html/css

CodeforcesRound#275(Div.2)BFriendsandPresents_html/css_WEB-ITnose:題目鏈接:Friends and Presents Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outpu
推薦度:
標(biāo)簽: css div2 #275
  • 熱門(mén)焦點(diǎn)

最新推薦

猜你喜歡

熱門(mén)推薦

專(zhuān)題
Top
主站蜘蛛池模板: 国产一区二区福利久久 | 国产第10页| 国产一区二区三区毛片 | 精品国产免费人成在线观看 | 国产欧美一区二区三区视频 | 伊人影院久久 | 精品国内自产拍在线视频 | 久久精品视频一区 | 羞羞网站在线观看 | 日本韩国一区二区 | 久久精品2| 97精品国产97久久久久久 | 国产一区在线看 | 欧美日韩不卡视频一区二区三区 | 欧美阿v高清资源在线 | 中文字幕一区久久久久 | 日本激情网址 | 国产免费一区二区三区香蕉精 | 国产一区二区不卡免费观在线 | 亚洲 自拍 另类 欧美 综合 | 久久久91精品国产一区二区 | 亚洲 欧美 自拍 另类 | 国产精品亚洲精品观看不卡 | 伊人网影院 | 国产欧美另类 | 中文亚洲欧美日韩无线码 | 国产一区二区视频在线 | 97国产精品欧美一区二区三区 | 欧美日韩一二三区 | 天天射综合 | 欧美日韩亚洲综合另类ac | 国产91精品久久久久999 | 亚洲va国产va欧美va综合 | 国产精品第十页 | 亚洲欧美在线观看 | 亚洲第一区在线观看 | 国产日韩欧美中文字幕 | 免费观看国产一区二区三区 | 国内精品免费 | 日本一道在线 | 青青草国产免费国产是公开 |