HDU 4430 amp; ZOJ 3665 Yukari#39;s Birthday(二分法+枚举)
生活随笔
收集整理的這篇文章主要介紹了
HDU 4430 amp; ZOJ 3665 Yukari#39;s Birthday(二分法+枚举)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
主題鏈接:
HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4430
ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?
problemId=4888
To make the birthday cake look more beautiful, Ran and Chen decide to place them like r ≥ 1 concentric circles. They place ki?candles equidistantly on the i-th circle, where k ≥ 2, 1 ≤ i ≤ r. And it's optional to place at most one candle at the center of the cake. In case that there are a lot of different pairs of r and k satisfying these restrictions, they want to minimize r × k. If there is still a tie, minimize r.
Input There are about 10,000 test cases. Process to the end of file.
Each test consists of only an integer 18 ≤ n ≤ 1012.
Output For each test case, output r and k.
Sample Input 18 111 1111
Sample Output 1 17 2 10 3 10
Source 2012 Asia ChangChun Regional Contest
題意:
要在一個蛋糕上放置 n 根蠟燭,擺成 r 個同心圓,每一個同心圓的蠟燭數為 k ^ i ,中間的圓心能夠放一根或者不放,使得 r * k 最小,若有多個答案輸出 r 最小的那個。
PS:
由于r是非常小的 !
枚舉r查找k。
代碼例如以下:(HDU,ZOJ上把64位換為long long就OK啦……)
版權聲明:本文博客原創文章,博客,未經同意,不得轉載。
轉載于:https://www.cnblogs.com/mfrbuaa/p/4734044.html
總結
以上是生活随笔為你收集整理的HDU 4430 amp; ZOJ 3665 Yukari#39;s Birthday(二分法+枚举)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FIneCMS /dayrui/libr
- 下一篇: SDWebImage实现原理(怎么实现图