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;
}
给出总的时间,给出不同情况的耗时,问最远可以跑多少
去的时候,如果是上坡的,返回的时候就变成了下坡,如果是下坡的,返回的时候就变成了上坡。路程是双程。
#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;
}
相关文章推荐
- POJ-3672-Long Distance Racing-水题、%c输入要去除换行
- POJ 3672 Long Distance Racing(水~)
- POJ 3672 Long Distance Racing (模拟)
- poj 3672 Long Distance Racing(水题)
- poj 3672 Long Distance Racing
- poj 3672 Long Distance Racing
- poj 3672 Long Distance Racing
- POJ 3672 Long Distance Racing G++
- (Relax ST1.29)POJ 3672 Long Distance Racing(来回路问题..)
- poj 3672 Long Distance Racing
- U - Long Distance Racing
- U - Long Distance Racing
- I - Long Distance Racing(第二季水)
- poj3672 Long Distance Racing留念下,惨痛的教训
- U - Long Distance Racing
- Long Distance Racing
- poj 1657 Distance on Chessboard
- POJ&nbsp;2774&nbsp;Long&nbsp;Lon…
- POJ 2774 Long Long Message(最长公共子串)
- POJ 2689 Prime Distance 素数筛选法应用