您的位置:首页 > 其它

POJ 3672 Long Distance Racing

2016-08-10 11:29 330 查看

给出总的时间,给出不同情况的耗时,问最远可以跑多少

去的时候,如果是上坡的,返回的时候就变成了下坡,如果是下坡的,返回的时候就变成了上坡。路程是双程。

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<deque>
#include<functional>
#include<iterator>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#define CPY(A,B)memcpy(A,B,sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fLL;
const double EPS=1e-9;
const double OO=1e20;
const double PI=acos (-1.0);
int dx[]= {0,1,0,-1};
int dy[]= {1,0,-1,0};
int gcd (const LL &a,const LL &b) {return b==0?a:gcd (b,a%b);}
using namespace std;
char unit[100010];
int main() {
int m,t,u,f,d;
cin>>m>>t>>u>>f>>d;
for (int i=0; i<t; i++) {
scanf (" %c",&unit[i]);
}
int ans=0,sum=0;
for (int i=0; i<t; i++) {
if (unit[i]=='u') {
sum+=u+d;
ans++;
} else if (unit[i]=='f') {
sum+=f+f;
ans++;
} else if (unit[i]=='d') {
sum+=d+u;
ans++;
}
if (sum>=m) {
printf ("%d\n",ans-1);
break;
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: