码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 670 A. Holidays(模拟)

时间:2016-08-20 00:12:47      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

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
Input
14
Output
4 4
Input
2
Output
0 2
Hint
In the first sample there are 14 days in a year on Mars, and therefore independently of the day a year starts with there will be exactly 4 days off .

In the second sample there are only 2 days in a year on Mars, and they can both be either work days or days off.

题目链接:http://codeforces.com/problemset/problem/670/A

***********************************************

题意:一周5天工作,2天休息 。现在有n天,但是你不知道第一天是星期几,问你最多放多少天,最少放多少天

分析:简单模拟。

7天为一个周期,如果求放假天数最小的时候就看成 1 2 3 4 5 6 7,

如果求放假天数最大就看成 6 7 1 2 3 4 5。

AC代码:

 

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<math.h>
 4 #include<queue>
 5 #include<algorithm>
 6 #include<time.h>
 7 #include<stack>
 8 using namespace std;
 9 #define N 1200000
10 #define INF 0x3f3f3f3f
11 
12 int dp[N];
13 int a[N];
14 
15 int main()
16 {
17     int n,l,r;
18 
19     while(scanf("%d", &n) != EOF)
20     {
21         if(n<2)
22             r=n,l=0;
23         else if(n<=5)
24             r=2,l=0;
25         else if(n<=7)
26             l=n-5,r=2;
27         else
28         {
29             if(n%7<2)
30             {
31                 l=n/7*2;
32                 r=n/7*2+n%7;
33             }
34             else if(n%7<=5)
35             {
36                  l=n/7*2;
37                  r=n/7*2+2;
38             }
39             else if(n%7<7)
40             {
41                 l=n/7*2+n%7-5;
42                 r=n/7*2+2;
43             }
44         }
45         printf("%d %d\n",l,r);
46     }
47     return 0;
48 }

 

 

 

 

 

 

 

 

 

CodeForces 670 A. Holidays(模拟)

标签:

原文地址:http://www.cnblogs.com/weiyuan/p/5789363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!