Codeforces Round #350 (Div. 2) A. Holidays 水题
A. Holidays
题目连接:
http://www.codeforces.com/contest/670/problem/A
Description
On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Martians have the same weeks as earthlings — 5 work days and then 2 days off. Your task is to determine the minimum possible and the maximum possible number of days off per year on Mars.
Input
The first line of the input contains a positive integer n (1 ≤ n ≤ 1 000 000) — the number of days in a year on Mars.
Output
Print two integers — the minimum possible and the maximum possible number of days off per year on Mars.
Sample Input
14
Sample Output
4 4
题意
一周5天工作,2天休息
现在有n天,但是你不知道第一天是星期几,问你最多放多少天,最少放多少天
题解:
n才1e6,所以直接莽一波就好啦~
其实直接数学也很简单,最多的,就是前面2天为寒假,最少的就是后两天了。
代码
#include<bits/stdc++.h>
using namespace std;
int n,mi=1e9,ma=0;
int main()
{
int n;scanf("%d",&n);
for(int i=0;i<7;i++)
{
int tmp=i,tmp2=0;
for(int j=0;j<n;j++)
{
if(tmp<2)tmp2++;
tmp=(tmp+1)%7;
}
mi=min(mi,tmp2);
ma=max(ma,tmp2);
}
cout<<mi<<" "<<ma<<endl;
}