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

A. Holidays

时间:2016-08-19 13:15:51      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:

http://codeforces.com/problemset/problem/670/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

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 4days 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.

题意:火星上没有闰年,但和地球一样有工作日和周末,先给出你一个天数,你求最小可能的放假天数和最大可能的放假天数。

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

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

#include<iostream>
#include<stack>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#define N 100100
using namespace std;
#define oo 0x3f3f3f
int dp[N];
int a[N],b[N];
int main()
{
    int t,n,s;

    while(scanf("%d",&n)!=EOF)
    {
        int a = n/7*2;
        int b = n % 7;
        if(b <=5)
            printf("%d ",a);
        else
            printf("%d ",a+b-5);

        if(n % 7 == 0)
        {
            int k = n / 7;
            printf("%d\n",k*2);
        }
        else
        {
            int x = n / 7 * 2;
            int y = n % 7;
            if(y >= 2)
                printf("%d\n",x+2);
            else
                printf("%d\n",x+y);
        }
    }
    return 0;
}

 

A. Holidays

标签:

原文地址:http://www.cnblogs.com/biu-biu-biu-/p/5786855.html

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