Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
又一个水题,咋没人做#include <iostream> #include <stdio.h> using namespace std; int main() { int cnt = 0; while(1){ int N; scanf("%d", &N); if(N < 0) break; cnt++; printf("Case %d:", cnt); double L[10]; int G[10], R[10], Y[10]; for(int i = 0; i < N; i++){ scanf("%lf%d%d%d", &L[i], &G[i], &Y[i], &R[i]); } bool state[66] = {0}; for(int s = 30; s <= 60; s++){ bool ky = 1; for(int i = 0; i < N; i++){ double t_ = L[i]/(s+0.0)*3600.0; int t = (int)(t_+1e-10); int shang = t/(G[i]+Y[i]+R[i]); if(t_-(G[i]+Y[i]+R[i])*shang > G[i]+Y[i]+1e-10){ ky = 0; break; } } if(ky) state[s] = 1; } int cur = 30; bool cc = 1; while(cur <= 60){ int start = -1; while(state[cur]){ if(start == -1) start = cur; cur++; } if(start == -1) { cur++; continue; } if(!cc) printf(","); cc = 0; printf(" "); if(cur-start == 1) printf("%d", start); else printf("%d-%d", start, cur-1); cur++; } if(cc) printf(" No acceptable speeds."); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator