Yukari's Birthday(精度处理) (二分)
来源:互联网 发布:淘宝小号交易 编辑:程序博客网 时间:2024/06/03 15:37
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 Description
Today 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 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.
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.
Each test consists of only an integer 18 ≤ n ≤ 1012.
Output
For 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); //规定上界 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; }
0 0
- Yukari's Birthday(精度处理) (二分)
- hdu 4430 Yukari's Birthday(二分)
- HDU 4430 Yukari's Birthday(枚举+二分)
- HDU4430 ——Yukari's Birthday (二分,快速幂)
- HDU4430:Yukari's Birthday(二分)
- HDU4430 Yukari's Birthday 二分
- hdu4430 Yukari's Birthday(二分)
- ZOJ 3665 Yukari's Birthday(12年长春区域赛-K题-二分)
- hdu 4430 Yukari's Birthday 枚举+二分
- hdu 4430 Yukari's Birthday(二分+枚举)
- Hdu 4430 Yukari's Birthday 枚举+二分
- HDU 4430 Yukari's Birthday (二分+枚举)
- zoj 3665 Yukari's Birthday(枚举+二分)
- HDU 4430 Yukari's Birthday 枚举+二分
- HDOJ 4430 Yukari's Birthday 【枚举】+【二分】
- HDU 4430 Yukari's Birthday(枚举+二分)
- HDU-4430-Yukari's Birthday-暴力+二分
- hdu4430 Yukari's Birthday 枚举+二分
- JXTA 简介
- Daily Sentence(2014~09)
- ACdream原创群赛(18)のAK's dream
- UVA Knights in FEN
- lucene3.5的创建和增删改查
- Yukari's Birthday(精度处理) (二分)
- Keil MDK
- Gson用户指南
- 第四天
- tomcat 配置访问路径 server.xml配置去掉项目名称 .
- 一个简单的蚁群算法
- 基于Cocos2d-x-3.2和vs2012的环境配置
- 由前序,中序求后序
- 黑马程序员-通过枚举实现单例模式