<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題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關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        CodeforcesRound#275(Div.2)BFriendsandPresents_html/css

        來源:懂視網 責編:小采 時間: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
        推薦度:
        導讀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有兩個朋友B和C,B和C都很喜歡數字,現在A要送給他們各自一些不同的數字來做禮物,但是B不喜歡素數x,所以不能送給他x的倍數;同樣如此,C不喜歡素數y,也不能送給他y的倍數。現在的任務是從找到一個最小的數v,使得從1~v里面可以滿足A的要求,分別送給B和C。



        解題思路:最開始寫的時候,用的是暴力枚舉,但是結果老是在一個樣例上錯,可能我的想法不對吧,得不到正確答案。后來看給出的官方解法是用二分。。想了半天,也沒想太明白,關鍵是想不好怎么用二分呀,該對誰二分,寫了這題,又漲姿勢了,原來可以從1到無窮大二分,感覺好神奇呀。二分,就要找好二分區間時的條件,根據題目要求,又想了想,才艱難的把這題給搞了。。



        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; //枚舉區間端點	while(l < r){ //二分	int mid = l + (r - l)/2;	if( n <= (mid - mid/x) && m <= (mid - mid/y) && n+m <= mid - mid/(x*y)) //劃分區間的條件	r = mid;	else	 	l = mid + 1;	}	printf("%d\n", r);	}	return 0;}

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。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
        推薦度:
        標簽: css div2 #275
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 97无码免费人妻超级碰碰碰碰| 91精品免费观看| 女性无套免费网站在线看| 亚洲国产精品人久久| 久久午夜夜伦鲁鲁片免费无码| 亚洲男人天堂2020| 亚洲午夜久久久影院| 亚洲一区中文字幕久久| 激情亚洲一区国产精品| 四虎成年永久免费网站 | 羞羞漫画页面免费入口欢迎你 | 亚洲三级在线免费观看| 亚洲大香伊人蕉在人依线| WWW国产亚洲精品久久麻豆| 成人黄网站片免费视频| 亚洲国产成人片在线观看| 黄色毛片免费在线观看| 亚洲性在线看高清h片| 成人自慰女黄网站免费大全| 天天摸天天碰成人免费视频| 久久人午夜亚洲精品无码区| 亚洲 小说区 图片区 都市| 亚洲欧洲日产v特级毛片| 亚洲人成网站免费播放| 黄色免费网址在线观看| 国产AV无码专区亚洲AV毛网站| 777成影片免费观看| 亚洲欧美日韩综合久久久| 久久久久久国产精品免费免费男同 | 日韩内射激情视频在线播放免费 | 亚洲第一成年男人的天堂| 精品女同一区二区三区免费站| 亚洲乱码中文字幕在线| 国产乱辈通伦影片在线播放亚洲| 一本色道久久88—综合亚洲精品 | 东北美女野外bbwbbw免费| 亚洲毛片无码专区亚洲乱| 国产一区二区三区在线免费观看 | 在线观看免费视频资源| 国产精品亚洲片在线花蝴蝶| 国产亚洲综合一区柠檬导航|