1017 Rate of Return
来源:互联网 发布:冒险岛079数据库 编辑:程序博客网 时间:2024/06/06 09:34
注意格式。
#include<iostream>#include<math.h>#include<stdio.h>using namespace std;struct word{int month;double depo;}wo[14];int N,month;double inve;double cal(double a){double sum=0;for(int i=0;i<N;i++){sum+=wo[i].depo*pow(a,wo[i].month);}return sum;}int main(){int numb=1;bool flag=0;while(cin>>N&&N!=-1){if(flag){cout<<endl;}for(int i=0;i<N;i++){cin>>month>>inve;wo[i].month=month;wo[i].depo=inve;}cin>>month>>inve;for(int i=0;i<N;i++){wo[i].month=month-wo[i].month+1;}double a=1.0;double b=2.0;double mid; while(1){mid=(a+b)/2.0;if(b-a<0.000001)break;double cal_mid=cal(mid);if(cal_mid==inve)break;if(cal_mid>inve){b=mid;continue;}if(cal_mid<inve){a=mid;continue;}}mid=mid-1;cout<<"Case "<<numb++<<": ";printf("%.5lf\n",mid);flag=1;}return 0;}
0 0
- 1017 Rate of Return
- 1017. Rate of Return
- 1017. Rate of Return
- sicily1017 Rate of Return
- Internal Rate Of Return - IRR
- sicily 1017. Rate of Return
- [sicily online]1017. Rate of Return
- UVA 11881(Internal Rate of Return)二分法
- UVA 11881 Internal Rate of Return
- toj 4609 Internal Rate of Return
- 1017. Rate of Return (用二分法求近似解)
- POJ-2199(一元n次方程,二分答案)(Rate of Return )
- 第六届省赛 E Internal Rate of Return(UVA 11881)二分求根
- POJ-2199 Rate of Return【二分求解一元高次方程】
- Principle of Rate Control Algorithm TMN5
- Success Rate of iBots in OBIEE
- Understanding different types of bit-rate encoding
- The Maximum Data Rate of a Channel
- Android开发资源
- 操作系统课堂笔记(7)设备管理
- 用PowerShell批量部署wsp包
- 上位机使用xmodem协议通过串口发送文件
- 高斯消去法
- 1017 Rate of Return
- 【LeetCode】Sum Root to Leaf Numbers
- 2>&1
- Ubuntu12.04下安装MyEclipse10
- eoe:开篇-记录EOE源码学习过程
- 3366彩色砖块外挂
- 黑马程序员_Java_网络编程(二)
- LNK2001:无法解析的外部符号 错误常见解决方法
- sqlserver数据库代码为角色分配权限