5500: 经营与开发
时间限制: 1 Sec 内存限制: 128 MB
提交: 66 解决: 42
[提交] [状态] [讨论版] [命题人:admin]
题目描述
4X概念体系,是指在PC战略游戏中一种相当普及和成熟的系统概念,得名自4个同样以“EX”为开头的英语单词。
eXplore(探索)
eXpand(拓张与发展)
eXploit(经营与开发)
eXterminate(征服)
——维基百科
今次我们着重考虑exploit部分,并将其模型简化:
你驾驶着一台带有钻头(初始能力值w)的飞船,按既定路线依次飞过n个星球。
星球笼统的分为2类:资源型和维修型。(p为钻头当前能力值)
1.资源型:含矿物质量a[i],若选择开采,则得到a[i]*p的金钱,之后钻头损耗k%,即p=p*(1-0.01k)
2.维修型:维护费用b[i],若选择维修,则支付b[i]*p的金钱,之后钻头修复c%,即p=p*(1+0.01c)
注:维修后钻头的能力值可以超过初始值(你可以认为是翻修+升级)
请作为舰长的你仔细抉择以最大化收入。
输入
第一行4个整数n,k,c,w。
以下n行,每行2个整数type,x。
type为1则代表其为资源型星球,x为其矿物质含量a[i];
type为2则代表其为维修型星球,x为其维护费用b[i];
输出
一个实数(保留2位小数),表示最大的收入。
样例输入
5 50 50 10 1 10 1 20 2 10 2 20 1 30
样例输出
375.00
提示
对于30%的数据 n<=100
另有20%的数据 n<=1000;k=100
对于100%的数据 n<=100000; 0<=k,c,w,a[i],b[i]<=100;保证答案不超过10^9
分析:其实问题关键就在于这个p,正着去想,对于当前星球挖还是不挖不好讨论,因为会影响到后面。所以干脆倒着往前来,影响的就是这个p,若在第i个星球挖了,那么i+1~n的星球都会受到影响,因为在这里p乘了一个k。所以倒着往前从ans=0开始。将ans*k+a[i](挖)与ans(不挖)作比较取最大值即可。
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
int n,w;
double k,c;
int type[MAX],x[MAX];
double ans=0.;
int main()
{
scanf("%d%lf%lf%d",&n,&k,&c,&w);
k=1-k*0.01,c=1+c*0.01;
for(int i=1;i<=n;i++) scanf("%d%d",&type[i],&x[i]);
for(int i=n;i>=1;i--)
{
if(type[i]==1)
ans=max(ans,ans*k+x[i]);
else
ans=max(ans,ans*c-x[i]);
}
printf("%.2lf\n",ans*w);
return 0;
}
368

被折叠的 条评论
为什么被折叠?



