[2016-05-06][codeforces][670A - Holidays]
时间:2016-05-06 09:48:21 星期五
题目编号:[2016-05-06][codeforces][670A - Holidays]
题目大意:假设没有闰年,7天中有5天工作,2天休息,给出一年的天数,问一年中,最少和最多有多少天休息.
分析:
- 一年中,看有多少个7天,记为t个,那么假期至少是t * 2 个7天
- 那么多出来的可能有 0 1 2 3 4 5 6 天
- 0 1 2 3 4 5 天的情况,里面可以有两天放假,也可以有都不放假
- 如果是 6的话,那么假期肯定还要多一天
遇到的问题:
- 注意余数是6的情况
#include<cstdio>using namespace std;int main(){int n;scanf("%d",&n);int ans = n / 7;printf("%d %d\n",ans*2 + ((n % 7) == 6 ? 1 : 0),ans * 2 + (n % 7 >= 2 ? 2 : n % 7));return 0;}
浙公网安备 33010602011771号