码迷,mamicode.com
首页 >  
搜索关键字:pow    ( 2646个结果
【c语言】c程序设计--谭浩强--(第三章)--2
// 假如我国国民生产总值的年增长率为9%,计算10年后我国国民生产总值与现在相比增长多少百分比 // p = ( 1 + r )^n r--年增长率 n--年数 p--与现在相比的倍数 #include #include int main() { double r = 0.09; double p; int n = 10; p = pow( ( 1 + r ) , n )...
分类:编程语言   时间:2015-04-14 18:01:57    阅读次数:238
POJ 2019 Power of Cryptography
技巧。 #include #include using namespace std; double n,p; int main(){ while(cin>>n>>p){ cout<<pow(p,1/n)<<endl; } }...
分类:其他好文   时间:2015-04-13 18:54:12    阅读次数:137
ZOJ 3868 GCD Expectation DP
dp[i] 表示公约数为i时有多少种组合 先预处理一遍dp[i]这是的dp[i]表示含有公约数i或者i的倍数的组合有多少个 再倒着dp dp[i] - = Sigma(dp[j]) (j是i的倍数 2i,3i,4i.....) 结果既为 Sigma[ dp[i]*pow(i,k) ] GCD Expectation Time Limit: 4 Seconds   ...
分类:其他好文   时间:2015-04-13 12:57:48    阅读次数:128
猴子吃桃问题
问题描述: 一群猴子摘了一堆桃子,他们每天都吃当前桃子的一半且再多吃一个,到了第十天就只剩余一个桃子,用多种方法求出这只猴子原来共摘了多少桃子。 解题思路: 代码如下: #include //scanf printf #include //system #include //pow int main() { system("mode con cols=100 lines=...
分类:其他好文   时间:2015-04-12 09:20:09    阅读次数:168
LeetCode-Pow(x, n)
Q: Implement pow(x, n).Note: 1. n = int.MinValue, Math.Abs(n) will overflow. For iterative, need to multiply x at the beginning, x value changes.2. n....
分类:其他好文   时间:2015-04-12 08:03:11    阅读次数:134
hdu 2199 Can you solve this equation
心情不好,简单的二分 #include #include #include using namespace std; double y; int cal(double x) { return 8*pow(x,4)+7*pow(x,3)+2*pow(x,2)+3*x+6; } double find() { double mid; double a,b; a=0;b=100; whil...
分类:其他好文   时间:2015-04-09 19:49:13    阅读次数:156
Pow(x,n)--LeetCode
题目: 实现pow() 思路:使用二分法,不过这道题用递归来解比较容易理解,把x的n次方划分成两个x的n/2次方相乘,然后递归求解子问题,结束条件是n为0返回1。因为是对n进行二分,算法复杂度和上面方法一样,也是O(logn)。代码如下: #include #include using namespace std; double pow(double x, int n) { if...
分类:其他好文   时间:2015-04-08 10:55:57    阅读次数:90
求方程解,牛顿迭代和二分
牛顿迭代#include#include#includeusing namespace std;float f(float x){ return (pow(x,3)-5*pow(x,2)+16*x+80);}float f1(float x){ return (3*pow(x,2)-5*...
分类:其他好文   时间:2015-04-07 23:01:51    阅读次数:112
[LeetCode] Pow(x, n) 二分搜索
Implement pow(x,n).Hide TagsMathBinary Search 题目很简单的。class Solution {public: double pow(double x, int n) { if(n==0) return 1; bool...
分类:其他好文   时间:2015-04-06 00:53:50    阅读次数:141
计算球的体积
#include#include#define PI 3.1415927int main(){double a;while(scanf("%lf",&a)!=EOF){ printf("%.3lf\n",4*PI*pow(a,3)/3);}}
分类:其他好文   时间:2015-04-03 09:16:48    阅读次数:87
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!