2013 ACM/ICPC Asia Regional Changsha Online Travel by Bike (基礎題)

Travel by Bike
Time Limit: 1 SecondMemory Limit: 32768 KB

Recently, Fancy is invited by his best friend to make a trip to his new house. Fancy is really excited by the invitation, so he's going to start the trip as soon as possible. But there are several difficulties to overcome. First, his friend is living in Changsha and Fancy is living in Hangzhou, so the trip is really a long one. Second, Fancy has only a bike to make this trip. Third, Fancy is a strange guy who would never work for longer than 8 hours on weekdays, and he would never work for longer than 4 hours on the weekend.

During this trip, Fancy thinks that riding bike is his only work. So on days of Monday to Friday, he will ride his bike 8 hours at most, and on Saturday and Sunday, he will ride 4 hours at most. Obviously, he will finish the trip as early as possible.

Now Fancy is going to start the trip, with information of road length and his riding speed, he wants to know that what day is his arriving day.


Input


There'll be several test cases. For each test case, there will be a string startday (startday ∈ {'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'}), an integer L (100 ≤ L ≤ 1000000000) and a float number s (5 ≤ s ≤ 30, with at most 3 decimal points). Here startday is the day which Fancy start the trip, L is the total length of the trip (in kilometer) and s is Fancy's riding speed (kilometer per hour).


Output


For each test case, please print the earlist day called arriveday which Fancy will arrive at Changsha. Please note that your output should fulfill arriveday ∈ {'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'}.


Sample Input


Monday 800 25.0
Sunday 300 5.0

Sample Output

Thursday

Monday


題意:

Fancy要去旅行,給你的信息是星期幾啓程、路程和車速。

行駛的條件是週一至週五可行駛8小時,週六至週日可行駛4小時,問到達目的地是星期幾?

思路:

對題意進行模擬即可。

注意:當正好行駛n個週期時,到達目的地的時間是出發時間的前一天。


/*************************************************************************
	> File Name: E.cpp
	> Author: BSlin
	> Mail:  
	> Created Time: 2013年09月22日 星期日 17時54分17秒
 ************************************************************************/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define MP make_pair
#define INF (1<<30)
#define PI acos(-1.0)
#define esp 1e-8
const int dx[4]={0,0,0,0};
using namespace std;
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#if defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__)
#define LL __int64
#define LLS "%" "I" "6" "4" "d"
#else
#define LL long long
#define LLS "%" "l" "l" "d"
#endif



enum Day{
    Monday = 1,
    Tuesday = 2,
    Wednesday = 3,
    Thursday = 4,
    Friday = 5,
    Saturday = 6,
    Sunday = 7,
}day;

int main(int argc, char** argv) {
    //read;
    char s[15];
    double length,speed,time;
    int num;

    while(scanf("%s%lf%lf",s,&length,&speed) != EOF) {
        if(s[0] == 'M') day = Monday;
        else if(s[0] == 'T'&&s[1]=='u') day = Tuesday;
        else if(s[0] == 'W') day = Wednesday;
        else if(s[0] == 'T'&&s[1] == 'h') day = Thursday;
        else if(s[0] == 'F') day = Friday;
        else if(s[0] == 'S'&&s[1] == 'a') day = Saturday;
        else if(s[0] == 'S'&&s[1] == 'u') day = Sunday;
        time = length / speed;
        num = (int)time / 48;
        time = time - num * 48;
        while(time - 48 >= esp) {
            time -= 48;
        }
        while((day <= 5 && time - 8 >= esp) || (day > 5 && day <= 7 && time - 4 >= esp)) {
            if(day == 1){
                time -= 8;
                day = Tuesday;
            }
            else if(day == 2) {
                time -= 8;
                day = Wednesday;
            }
            else if(day == 3) {
                time -= 8;
                day = Thursday;
            }
            else if(day == 4) {
                time -= 8;
                day = Friday;
            }
            else if(day == 5) {
                time -= 8;
                day = Saturday;
            }
            else if(day == 6) {
                time -= 4;
                day = Sunday;
            }
            else if(day == 7) {
                time -= 4;
                day = Monday;
            }
        }
        if(day == 1){
            if(time < esp) printf("Sunday\n");
            else printf("Monday\n");
        }
        else if(day == 2) {
            if(time < esp) printf("Monday\n");
            else printf("Tuesday\n");
        }
        else if(day == 3) {
            if(time < esp) printf("Tuesday\n");
            else printf("Wednesday\n");
        }
        else if(day == 4) {
            if(time < esp) printf("Wednesday\n");
            else printf("Thursday\n");
        }
        else if(day == 5) {
            if(time < esp) printf("Thursday\n");
            else printf("Friday\n");
        }
        else if(day == 6) {
            if(time < esp) printf("Friday\n");
            else printf("Saturday\n");
        }
        else if(day == 7) {
            if(time < esp) printf("Saturday\n");
            else printf("Sunday\n");
        }
    }
    return 0;
}



發佈了45 篇原創文章 · 獲贊 6 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章