2013长沙网赛E题Travel by Bike

题目链接:http://acm.zju.edu.cn/changsha/showProblem.do?problemId=26

题意:一个人从一个地方到另一个地方,长度为L,每小时速度为speed,周一到周五每天最多走8个小时,周末最多走4个小时,给出这个人出发的时间,问周几到达。

分析:水题,但是有个地方要注意,刚好是周期的倍数的时候,应该是当前天的前一天。

AC代码:

 1 #include<stdio.h>
 2 #include<string.h>
 3 char s[10];
 4 char day[7][10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
 5 int main()
 6 {
 7     int i,d;
 8     double speed,L;
 9     while(scanf("%s%lf%lf",s,&L,&speed)!=EOF)
10     {
11         for(i=0;i<7;i++)
12             if(strcmp(s,day[i])==0)
13                 d=i;
14         int a=L/speed;
15         if(L-a*speed>=10e-6)
16             a++;
17         int b=a%48;
18         if(b==0)
19             d=(d+6)%7;
20         else
21         {
22             while(b>0)
23             {
24                 if(d>=0&&d<=4)
25                     b-=8;
26                 else
27                     b-=4;
28                 if(b>0)
29                     d=(d+1)%7;
30             }
31         }
32         printf("%s\n",day[d]);
33     }
34     return 0;
35 }
View Code

 

 

转载于:https://www.cnblogs.com/frog112111/p/3334754.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值