Yukari's birthday (precision processing) (Binary)

Source: Internet
Author: User
Yukari's birthday Time Limit: 12000/6000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 2910 accepted submission (s): 610


Problem descriptiontoday is Yukari's n-th birthday. Ran and Chen hold a celebration party for her. Now comes the most important part, birthday cake! But it's a big challenge for them to place n candles on the top of the cake. as Yukari has lived for such a long time, though she herself insists that she is a 17-year-old girl.
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.
 
Inputthere are about 10,000 test cases. process to the end of file.
Each test consists of only an integer 18 ≤ n ≤ 1012.
 
Outputfor each test case, output R and K.
Sample Input
181111111
 
Sample output
1 172 103 10
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # define LH _ int64 using namespace STD; LH powll (lh x, int y) {LH res = 1; for (INT I = 0; I <Y; I ++) {res * = x ;} return res;} int main () {lh n; lh r, K; while (~ Scanf ("% i64d", & N) {r = 1; k = n-1; lh ll, RR, mm; for (INT I = 2; I <= 45; I ++) {ll = 2; RR = (LH) Pow (n, 1.0/I); // specifies the upper bound while (LL <= RR) {mm = (LH) (LL + RR)/2; LH ans = (Mm-powll (mm, I + 1)/(1-mm ); if (ANS = n | ans = N-1) {if (I * mm <r * k) {r = I; k = mm;} break ;} else if (ANS> N) RR = mm-1; else LL = mm + 1 ;}} printf ("% i64d % i64d \ n", R, k );} return 0 ;}


Yukari's birthday (precision processing) (Binary)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.