poj 3639 dp
来源:互联网 发布:linux编程基础 编辑:程序博客网 时间:2024/06/05 02:36
Description
Now that the Loonie is hovering about par with the Greenback, you have decided to use your $1000 entrance scholarship to engage in currency speculation. So you gaze into a crystal ball which predicts the closing exchange rate between Canadian and U.S. dollars for each of the next several days. On any given day, you can switch all of your money from Canadian to U.S. dollars, or vice versa, at the prevailing exchange rate, less a 3% commission, less any fraction of a cent.
Assuming your crystal ball is correct, what's the maximum amount of money you can have, in Canadian dollars, when you're done?
Input
The input contains a number of test cases, followed by a line containing 0. Each test case begins with 0 < d ≤ 365, the number of days that your crystal ball can predict. d lines follow, giving the price of a U.S. dollar in Canadian dollars, as a real number.
Output
Sample Input
31.05000.93000.990021.05001.10000
Sample Output
1001.601000.00
#include <iostream>#include <vector>#include <map>#include <set>#include <queue>#include <stack>#include <algorithm>#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <ctime>using namespace std;#define LL long long#define clr(s,x) memset(s,x,sizeof(s))#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const double PI = acos(-1.0);const LL mod = 1e9+7;const int maxn=1005;double dp[maxn][2];double per[maxn];double get_ans(double x){ x=x*100.0; int xx=(int)x; return xx/100.0;}int main(){ int n; while(cin>>n){ clr(dp,0); clr(per,0); if(n==0)break; for(int i=1;i<=n;i++){ cin>>per[i]; } dp[0][0]=1000.0;// ca dp[0][1]=0;//us for(int i=1;i<=n;i++){ dp[i][0]=max(dp[i-1][0],get_ans(dp[i-1][1]*per[i]*0.97)); dp[i][1]=max(dp[i-1][1],get_ans(dp[i-1][0]/per[i]*0.97)); } printf("%.2f\n",dp[n][0]); } return 0;}
- poj 3639 dp
- poj dp
- 【dp】POJ
- 【dp】POJ
- [DP] POJ
- [DP] POJ
- [DP] POJ
- 【dp】POJ
- POJ 3670 && POJ 3671 (dp)
- 【DP】 POJ 1080
- poj 1163经典DP
- poj 1088 滑雪(DP)
- poj 1770 树形dp
- POJ 1179 Polygon(DP)
- POJ 1221 dp
- POJ 1953 DP
- POJ 2033 DP
- POJ 1179 Polygon DP
- 前端上传组件Plupload使用指南 与swfupload一样强大
- 判断回文的方法总结
- Android;Share SDK微信分享中遇到的问题以及解决方法
- android对handler及asynctask的一个例子
- Js jq获取select值
- poj 3639 dp
- Gnome的配置参数管理
- 对Memcached使用的总结和使用场景
- block的实现原理
- AMQP机制
- WEB版一次选择多个文件进行批量上传(Plupload)的解决方案
- 详解UML中的关系(泛化、实现、依赖、关联【聚合、组合】)
- PUUPLOAD 上传文件范例
- 使用官方Fedora22 ISO镜像制作OpenStack云镜像