比赛 |
20111109 |
评测结果 |
AAAAAAAAAA |
题目名称 |
摩托车游戏 |
最终得分 |
100 |
用户昵称 |
fanzeyi |
运行时间 |
0.000 s |
代码语言 |
C |
内存使用 |
0.00 MiB |
提交时间 |
2011-11-09 10:18:14 |
显示代码纯文本
/*
ID: fanzeyi1
LANG: C
TASK: carz
*/
/*
* =====================================================================================
*
* Filename: carz.c
* Version: 1.0
* Created: 11/09/2011 09:14:56 AM
* Revision: none
* Compiler: gcc
* Author: Zeray Fan, fanzeyi1994[at]gmail.com
* Company: http://www.fanhe.org/
*
* =====================================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 1001
double speed(int a) {
if(a > 4) {
return 7.0;
}else if(a > 3) {
return 7.5;
}else if(a > 2) {
return 8.0;
}else if(a > 1) {
return 9.0;
}else{
return 10.0;
}
}
inline double min(double a, double b) {
return a < b ? a : b;
}
int main(void) {
FILE *fin = fopen("carz.in","r");
FILE *fout = fopen("carz.out", "w");
int i, j;
int s, t;
double th;
double f[MAX];
fscanf(fin, "%d %d\n", &s, &t);
s = s / 10;
th = t / 60.0;
memset(f, 0x7f, sizeof(f));
f[0] = 0.000;
for( i = 1 ; i <= s ; i++ ) {
for( j = 0 ; j < i ; j++ ) {
if(j == 0) {
f[i] = min(f[i], f[j] + (i - j) / speed(i - j));
}else{
f[i] = min(f[i], f[j] + (i - j) / speed(i - j) + th);
}
}
}
fprintf(fout, "%.2lf\n", f[s]);
return 0;
}