zoukankan      html  css  js  c++  java
  • Codeforces Round #350 (Div. 2) A

    A. Holidays
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Examples
    Input
    14
    Output
    4 4
    Input
    2
    Output
    0 2
    Note

    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.

    题意: 假设一年有n天 问一年内的休息天的数量(一周7天 5+2) 的最小值与最大值

    题解:最小值---从周一开始算

             最大值---从周六开始算

       比赛的时候这题都gg了 没处理好 菜

     1 #include<bits/stdc++.h>
     2 #include<iostream>
     3 #include<cstring>
     4 #include<cstdio>
     5 #include<queue>
     6 #include<stack>
     7 #include<map> 
     8 #define ll __int64
     9 #define pi acos(-1.0)
    10 using namespace std;
    11 int n;
    12 int main()
    13 {
    14     while(scanf("%d",&n)!=EOF)
    15     {
    16     int s1;
    17     if(n>=7)
    18     {
    19       s1=(n/7)*2;
    20       if(n%7==6)
    21       s1+=1; 
    22     }
    23     else
    24     {
    25      if(n==6)
    26      s1=1;
    27      else
    28      s1=0;
    29     }
    30     int s2=2;
    31     if(n-2>=7)
    32     { 
    33       s2+=((n-2)/7*2);
    34       if((n-2)%7==6)
    35          s2+=1;
    36     }
    37     else
    38     {
    39      if(n-2==6)
    40      s2+=1;
    41      else
    42      s2+=0;
    43     }
    44     if(n>2)
    45     printf("%d %d
    ",s1,s2);
    46     if(n==1)
    47     printf("0 1
    ");
    48     if(n==2)
    49     printf("0 2
    ");
    50 }
    51     return 0; 
    52 } 
  • 相关阅读:
    react-router刷新页面Cannot GET 问题
    react学习之弹出层
    react学习之js-xlsx导入和导出excel表格
    c#串口通信并处理接收的多个参数
    react与微信小程序
    promise知识点小结
    汇编命令小记
    Firebase-config 在android中的使用
    python:html元素解析
    Toast实现源码解析
  • 原文地址:https://www.cnblogs.com/hsd-/p/5464441.html
Copyright © 2011-2022 走看看