zoukankan      html  css  js  c++  java
  • [Codeforces670A]Holidays(数学,构造)

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

    题意:给n天,问这n天最少和最多有多少个休息日,不用区分平闰年。

    这题写几个例子,YY一下就构造出来解了。

    首先注意到了n是7的倍数的时候,无论从周几开始总会轮回回去,因此休息日最多最少是相同的。

    n是1的时候要特判,结果是0和1就不多说了。

    对于一般情况,需要注意的就是两头有一天的情况了,(比如n=8,最少有2个休息日,最多有3个)

     1 /*
     2 ━━━━━┒ギリギリ♂ eye!
     3 ┓┏┓┏┓┃キリキリ♂ mind!
     4 ┛┗┛┗┛┃\○/
     5 ┓┏┓┏┓┃ /
     6 ┛┗┛┗┛┃ノ)
     7 ┓┏┓┏┓┃
     8 ┛┗┛┗┛┃
     9 ┓┏┓┏┓┃
    10 ┛┗┛┗┛┃
    11 ┓┏┓┏┓┃
    12 ┛┗┛┗┛┃
    13 ┓┏┓┏┓┃
    14 ┃┃┃┃┃┃
    15 ┻┻┻┻┻┻
    16 */
    17 #include <algorithm>
    18 #include <iostream>
    19 #include <iomanip>
    20 #include <cstring>
    21 #include <climits>
    22 #include <complex>
    23 #include <fstream>
    24 #include <cassert>
    25 #include <cstdio>
    26 #include <bitset>
    27 #include <vector>
    28 #include <deque>
    29 #include <queue>
    30 #include <stack>
    31 #include <ctime>
    32 #include <set>
    33 #include <map>
    34 #include <cmath>
    35 using namespace std;
    36 #define fr first
    37 #define sc second
    38 #define cl clear
    39 #define BUG puts("here!!!")
    40 #define W(a) while(a--)
    41 #define pb(a) push_back(a)
    42 #define Rlf(a) scanf("%lf", &a);
    43 #define Rint(a) scanf("%d", &a)
    44 #define Rll(a) scanf("%I64d", &a)
    45 #define Rs(a) scanf("%s", a)
    46 #define Cin(a) cin >> a
    47 #define FRead() freopen("in", "r", stdin)
    48 #define FWrite() freopen("out", "w", stdout)
    49 #define Rep(i, len) for(int i = 0; i < (len); i++)
    50 #define For(i, a, len) for(int i = (a); i < (len); i++)
    51 #define Cls(a) memset((a), 0, sizeof(a))
    52 #define Clr(a, x) memset((a), (x), sizeof(a))
    53 #define Full(a) memset((a), 0x7f7f, sizeof(a))
    54 #define lrt rt << 1
    55 #define rrt rt << 1 | 1
    56 #define pi 3.14159265359
    57 #define RT return
    58 #define lowbit(x) x & (-x)
    59 #define onenum(x) __builtin_popcount(x)
    60 typedef long long LL;
    61 typedef long double LD;
    62 typedef unsigned long long ULL;
    63 typedef pair<int, int> pii;
    64 typedef pair<string, int> psi;
    65 typedef map<string, int> msi;
    66 typedef vector<int> vi;
    67 typedef vector<LL> vl;
    68 typedef vector<vl> vvl;
    69 typedef vector<bool> vb;
    70 
    71 int n;
    72 
    73 int main() {
    74     // FRead();
    75     while(~Rint(n)) {
    76         if(n % 7 == 0) {
    77             printf("%d %d
    ", n / 7 * 2, n / 7 * 2);
    78             continue;
    79         }
    80         if(n == 1) {
    81             printf("%d %d
    ", 0, 1);
    82             continue;
    83         }
    84         if(n % 7 <= 5) printf("%d ", n / 7 * 2);
    85         else printf("%d ", n / 7 * 2 + 1);
    86         n -= 2;
    87         if(n % 7 <= 5) printf("%d ", n / 7 * 2 + 2);
    88         else printf("%d ", n / 7 * 2 + 3);
    89     }
    90     RT 0;
    91 }
  • 相关阅读:
    【C#】调度程序进程已挂起,但消息仍在处理中;
    【WCF】wcf不支持的返回类型
    power design教程
    C# 动态修改Config
    【C#】delegate(委托) 将方法作为参数在类class 之间传递
    【.NET】Nuget包,把自己的dll放在云端
    【C#】C# 队列,
    【Chrome】新建Chrome插件,新建,事件行为,本地存储
    【IIS】iis6.1下添加两个ftp站点,
    【Jquery】$.Deferred 对象
  • 原文地址:https://www.cnblogs.com/kirai/p/5556132.html
Copyright © 2011-2022 走看看