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

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

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

#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;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值