poj 3100 && zoj 2818 ( Root of the Problem ) (睡前一水)
2015-01-25 23:15
483 查看
链接:click here
题意:
Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be less than, equal to, or greater than B.
.给你B和N,求个整数A使得A^n最接近B
不解释,代码:
题意:
Given positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be less than, equal to, or greater than B.
.给你B和N,求个整数A使得A^n最接近B
不解释,代码:
//zoj 2818 poj 3100 #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h> #include <math.h> using namespace std; int main() { double b,n; while(cin>>b>>n&&b&&n) { int a=(int )pow(b,1/n); //cout<<pow(a,n)<<endl; if(b-pow(a,n)<pow(a+1,n)-b) cout<<a<<endl; else cout<<a+1<<endl; } return 0; }
相关文章推荐
- POJ 3100 & ZOJ 2818 & HDU 2740 Root of the Problem(数学)
- POJ 3100 & ZOJ 2818 & HDU 2740 Root of the Problem(数学)
- zoj 2818 || poj 3100 Root of the Problem(水! = =)
- POJ 3100 && HDU 2740 Root of the Problem(水~)
- zoj 2818 Root of the Problem(数学思维题)
- POJ_3100_Root of the Problem(暴力)
- POJ 3100:Root of the Problem
- POJ 3100 Root of the Problem(我的水题之路——取A^N最接近B的A)
- POJ 3100 Root of the Problem G++
- POJ 3100 Root of the Problem 可能会
- poj 3100 Root of the Problem
- poj 3100 Root of the Problem
- POJ-3100-Root of the Problem,原来是水题,暴力求解~~~
- a的n次幂 —— POJ 3100 Root of the Problem
- POJ 3100 Root of the Problem
- zoj 2818 Root of the Problem
- zoj 2818 Root of the Problem
- POJ 3100 Root of the Problem || 1004 Financial Management 洪水!!!
- POJ 3100 Root of the Problem || 1004 Financial Management 洪水!!!
- zoj2818 Root of the Problem 简单数学 开方