2013regional长沙赛区网赛E题--Travel by Bike

来源:互联网 发布:咸鱼纠纷淘宝怎么处理 编辑:程序博客网 时间:2024/04/29 03:59

题意:从一个星期的某一天开始行走,工作日行走八个小时,周末行走四个小时,现给出总路程和行走速率,问走完这段路程是在星期几。

题解:为了方便计算,把所有的开始的那一天推移到星期一,即在总时间上加上要往前推的时间,然后直接模拟就可以了。

#include<stdio.h>#include<iostream>#include<string>#include<algorithm>#include<string.h>#include<math.h>using namespace std;int main(){    char str[10];    double tim,len;    while (scanf("%s%lf%lf",str,&tim,&len)!=EOF)    {        double all;        long long l,r;            all=tim/len;        if (str[0]=='T'&&str[1]=='u')all+=8;        if (str[0]=='W'&&str[1]=='e')all+=16;        if (str[0]=='T'&&str[1]=='h') all+=24;        if (str[0]=='F')all+=32;        if (str[0]=='S'&&str[1]=='a') all+=40;        if (str[0]=='S'&&str[1]=='u') all+=44;            l=ceil(all);            r=floor(all);            int tmp=l%48;            if (0<tmp&&tmp<=8) printf("Monday\n");            if (8<tmp&&tmp<=16) printf("Tuesday\n");            if (16<tmp&&tmp<=24) printf("Wednesday\n");            if (24<tmp&&tmp<=32) printf("Thursday\n");            if (32<tmp&&tmp<=40) printf("Friday\n");            if (40<tmp&&tmp<=44) printf("Saturday\n");            if (44<tmp&&tmp<48||tmp==0) printf("Sunday\n");    }    return 0;}


原创粉丝点击