SSL P2759 挖矿
来源:互联网 发布:完美丈夫网络剧 编辑:程序博客网 时间:2024/05/29 19:03
题目大意:
题解:
然后为什么呢?
因为如果获得了当前的a[i],后面的开采就都要减少,即失去了百分之K
然后如果维护了当前的b[i],后面的开采就都要增加,即多出了百分之C
然后DP同理可以推出,详见程序
90分????咦惹,卡我精度!
var a:array [0..200001,1..2] of longint; k,c,ans,m:extended; n,i,j:longint;function max(aa,bb:extended):extended;begin if aa>bb then exit(aa); exit(bb);end;begin readln(n,k,c,m); for i:=1 to n do readln(a[i,1],a[i,2]); k:=1-0.01*k; c:=1+0.01*c; for i:=n downto 1 do begin if a[i,1]=1 then ans:=max(ans,ans*k+a[i,2]) else ans:=max(ans,ans*c-a[i,2]); end; writeln(ans*m:0:2);end.
因为题库的答案只有一个,所以我很幸运的被卡精度了!
但洛谷我的P A了,因为考虑了精度多判断了几个答案的可行性。
这是某dalao帮我翻C的~
#include <stdio.h>#include <string>#include <cstring>#include <algorithm>using namespace std;#define maxn 100001struct arr{ int type, w;}e[maxn];double k, c;double f[maxn];int main(){ int n, w; scanf("%d%lf%lf%d", &n, &k, &c, &w); for (int i = 1; i <= n; i++) { scanf("%d%d", &e[i].type, &e[i].w); } double ans = 0; k = 1 - 0.01 * k; c = 1 + 0.01 * c; for (int i = n; i >= 1; i--) { if (e[i].type == 1) ans = max(ans, ans * k + e[i].w); else ans = max(ans, ans * c - e[i].w); } printf("%.2lf\n", ans * w);}
阅读全文
0 0
- SSL P2759 挖矿
- 洛谷 P2759 奇怪的函数
- 洛谷 P2759 奇怪的函数
- luogu p2759 奇怪的函数Solution
- SSL
- SSL
- ssl
- SSL
- ssl
- ssl
- SSL
- SSL
- SSL
- ssl
- SSL
- ssl
- SSL
- SSL
- (6.0及以上)运行时获取危险权限(Dangerous Permission)
- 【笔记】软件与软件工程浅谈
- JAVA12
- KindEditor上传文件时报500错误
- hdu 3552 I can do it! (思维)
- SSL P2759 挖矿
- JAVA12
- linux命令--htop
- Javascript函数引用时加括号与不加括号的区别
- 命令行参数 opencv调用
- Qt快速入门
- vue 中用less 解决背景图片根据屏幕选择问题
- 泛型总结
- iOS把图片缓存到本地的几种方法