toj 4609 Internal Rate of Return

时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte
总提交: 17 测试通过:11

描述

In finance, Internal Rate of Return (IRR) is the discount rate of an investment when NPV equals zero. Formally, given T, CF0, CF1, …, CFT, then IRR is the solution to the following equation:

Your task is to find all valid IRRs. In this problem, the initial cash-flow CF0 < 0, while other cash-flows are all positive (CFi > 0 for all i = 1, 2,…).

Important: IRR can be negative, but it must be satisfied that IRR > - 1.

输入

There will be at most 25 test cases. Each test case contains two lines. The first line contains a single integer T ( 1≤T≤10), the number of positive cash-flows. The second line contains T + 1 integers: CF0, CF1, CF2, …, CFT, where CF0 < 0, 0 < CFi < 10000 ( i = 1, 2,…, T). The input terminates by T = 0.

输出

For each test case, print a single line, containing the value of IRR, rounded to two decimal points. If no IRR exists, print “No” (without quotes); if there are multiple IRRs, print “Too many”(without quotes).

样例输入

1
-1 2
2
-8 6 9
0

样例输出

1.00
0.50

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
#define eps 1e-5int main()
{int T, s[10000];while(scanf("%d", &T) && T){memset(s, 0, sizeof(s));for(int i = 0; i <= T; i++){scanf("%d", &s[i]);}//printf("%d\n", s[0]);double Q = 0;double left = -1;double right = 10000;int flag = 1;double mid = 0;while(1){mid = (left + right) / 2;//cout << mid << endl;Q = s[0];for(int i = 1; i <= T; i++){if((1+mid) == 0){flag = 0;break;}Q += s[i]/pow(1+mid, i*1.0);//cout << Q << endl;}if(flag == 0){flag == 1;continue;}if(Q > eps)left = mid;else if(Q < -eps)right = mid;if(Q <= eps && Q >= -eps)break;}printf("%.2lf\n", mid);}return 0;
}

toj 4609 Internal Rate of Return相关推荐

  1. 必要回报率(Required Rate Of Return)

    必要回报率(Required Rate Of Return)是投资者在投资之前需要考虑获得的最低回报率,这需要考虑以下几个因素: time value of money inflation risk ...

  2. excel两个指标相关性分析_Excel实操分析函数,投资决策指标的假设分析,就是那么简单...

    投资决策中经常需要对多个指标的变化同时进行考量.例如假定某项投资期初投入500万元,同时假定年折现率(贴现率)为 3%,计划第一年年末收回投资 50 万,第二年年末收回 100 万,第三年年末收回15 ...

  3. PMP考试资料:这个项目值得去做吗

    5.4.2 这个项目值得去做吗 有的时候我们会面临这样的问题:有多个项目可以选择,而资源却有限,或针对项目的投资前景不是十分清楚,那么我们应该进行这个项目吗?下面介绍几种用于项目选择与评估的财务管理工 ...

  4. 信息系统项目管理师-常用术语中英文对应

    常用术语中英文对应 SOW(Statement of Work,工作说明书) WBS(Work Breakdown Structure,工作分解结构) OBS(Organizational Break ...

  5. 成本管理4个过程及相关重点

    目录 概述 成本失控的原因 成本的类型 1.规划成本管理 2.估算成本 3.预算成本 4.控制成本 名词解释 应急储备和管理储备 成本基准 技术分析 三点估算 自下而上估算 挣值管理(EVM) 预测 ...

  6. IT项目管理总结:第四章 项目综合管理

    第四章 项目综合(Integration)管理 什么是项目综合管理 –它涉及在整个项目生命周期中协调所有其他项目管理的知识领域 –主要包括以下六个主要过程: A)制定项目章程(project char ...

  7. bloomberg用法 固定收益_内部收益率的用法浅谈某保险的真实收益率

    公司财务课程,魏教授讲得非常棒,治愈了大家的瞌睡,激起了大家的学习热情.我一直认为,大牛在讲课,吹牛还是演讲中,都能够给现场观众提供强大的能量,使得彼此运行在同一个共振频率. 内部收益率(Intern ...

  8. python 内部收益率_python – IRR实现中使用的数值方法是什么?

    ActiveState Recipes站点具有在Python中实现 Internal Rate of Return的功能: def irr(cashflows, iterations=100): &q ...

  9. NumPy Beginner's Guide 2e 带注释源码 七、NumPy 特殊例程

    # 来源:NumPy Biginner's Guide 2e ch7 字典排序 import numpy as np import datetime# 日期转成字符串 def datestr2num( ...

最新文章

  1. 是时候取消Sprint评审会议了吗?
  2. git commit —amend_Git之修改commit记录
  3. 如何将一键还原精灵备份文件复制出来?
  4. 高级指令——kill指令、ifconfig指令、reboot指令、shutdown指令、uptime指令、uname指令
  5. postman模拟文件上传接口
  6. 【SpringBoot零基础案例02】【IEDA 2021.1】SpringBoot框架集成SpringMVC
  7. jqgrid编辑php,php – 实现jqgrid单元格编辑datepicker
  8. hdu 1811Rank of Tetris (并查集 + 拓扑排序)
  9. Delaunay三角化实现原理
  10. 机器学习之使用sklearn构造决策树模型
  11. 直线电机原理动画_直线振动筛工作原理结构图以及结构解析
  12. Java汽车销售系统
  13. 电机转矩、功率、转速之间的关系及计算公式
  14. 卸载ie8的一些方法
  15. 使用regexp_extract、regexp_replace函数过滤特殊字符时,不同的执行情境下(hive -e;hive -f),正则表达式的内容有变化
  16. passwd_pro
  17. codewhy_vue笔记01
  18. unity微信分享及回调
  19. Flume介绍和使用
  20. mapDispatchToProps

热门文章

  1. OSPF——GRE Tunnel(含配置命令)详解
  2. Python3标准库:asyncio异步I/O、事件循环和并发工具
  3. springboot 全局异常处理 自定义mvc错误页面展示
  4. 【Python】循环的拓展
  5. 如何优化Jupyter Notebook
  6. Python中的Series和DataFrame
  7. java怎么计算等式_谁能解释计算这个等式的步骤? Java的
  8. 使用TA-Lib在vn.trader上开发CTA交易策略
  9. MySQL的数据类型和约束
  10. ExtJS之Store