本文主要是介绍POJ 3672 Long Distance Racing(水题),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
点击打开链接
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;int main()
{map<char, int> mp;int M,T,U,F,D;int a[maxn];while(~scanf("%d%d%d%d%d",&M,&T,&U,&F,&D))//总时间、{memset(a, 0, sizeof(a));mp['u'] = U;mp['f'] = F;mp['d'] = D;char ch;int sum = 0;int ans = 0;for(int i = 0; i < T; i++){cin >> ch;if(sum <= M){sum += mp[ch];if(ch == 'f') sum += mp['f'];if(ch == 'u') sum += mp['d'];if(ch == 'd') sum += mp['u'];if(sum <= M)ans++;}//a[i] = mp[ch];//cout << a[i] << endl;}printf("%d\n",ans);}return 0;
}
这篇关于POJ 3672 Long Distance Racing(水题)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!