zoukankan      html  css  js  c++  java
  • CodeForces 670 A. Holidays(模拟)

    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
    ",l,r);
    46     }
    47     return 0;
    48 }
  • 相关阅读:
    ORACLE 当字段中有数据如何修改字段类型
    ORACLE 语句
    对接支付宝支付接口开发详细步骤
    生成uuid
    DataGrip如何连接和移除MySQL数据库
    iOS提交AppStore被拒原因
    swift系统学习第二章
    swift系统学习第一章
    iOS开发:JavaScriptCore.framework的简单使用--JS与OC的交互篇
    iOS开发:微信支付
  • 原文地址:https://www.cnblogs.com/weiyuan/p/5789363.html
Copyright © 2011-2022 走看看