?? 2142.cpp
字號:
/* This Code is Submitted by wywcgs for Problem 2142 on 2006-02-25 at 22:54:26 */
#include <cstdio>
#include <cctype>
#include <cmath>
const int L_MAX = 256;
const int MAX = 32768;
class Inhabitant {
public:
double pos;
char name[L_MAX], dir;
void make();
double path(double) const;
};
void Inhabitant::make() {
scanf("\n%c %lf %s", &dir, &pos, name);
if(isupper(dir)) dir -= 'A'-'a';
}
double Inhabitant::path(double len) const {
return (dir == 'p') ? len-pos : pos;
}
Inhabitant in[MAX];
int main()
{
int i, n;
while(scanf("%d", &n) != EOF && n != 0) {
double l, v; scanf("%lf %lf", &l, &v);
for(i = 0; i < n; i++) in[i].make();
double last = 0; int lo;
for(i = 0; i < n; i++) {
double time = in[i].path(l) / v;
if(last < time) last = time, lo = i;
}
int neg = 0;
for(i = 0; i < n; i++)
if(in[i].dir == in[lo].dir) continue;
else if(in[lo].dir == 'p' && i > lo) neg++;
else if(in[lo].dir == 'n' && i < lo) neg++;
lo += (in[lo].dir == 'p') ? neg : -neg;
printf("%13.2lf %s\n", floor(100*last)/100, in[lo].name);
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -