codeforces 670A Holidays

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.

#include <iostream>
#include <cstring>
using namespace std;
int main(){
    int n,l,r;
    cin>>n;
    l=r=n/7*2;
    int mod=n%7;
    if(mod==1) r+=1;
    else if(mod>=2&&mod<=5) r+=2;
    else if(mod==6) l+=1,r+=2;
    cout<<l<<' '<<r<<endl;
    return 0;
}

阅读更多

Holidays

08-22

You must know that our country is well known for its strange holidays system. We celebrate anything we can, and often new public holidays are announced, though sometimes some are cancelled.nnIn year 3141 some archeologists have discovered the document that they consider to be the log of changes in the system of public holidays in our country from year Ys till year Yf , inclusively. Each record of the document has the formnn, added norn, removed nThe record of the first type means that the public holiday on was announced on day , and the record of the second type means that the public holiday on was cancelled on day .nnUnfortunately, all dates of records only include day and month, but not the year. Now the archeologists wonder, what maximal number of public holidays could have been there during the years described. Your task in this problem is to answer this question and provide the version of the document with years inserted, that would guarantee this number of the holidays.nnYou must assume that all records in the document are in the chronological order and that there were no day when two different events took place, that is, all dates of records in the document must be different.nnNote that if the holiday was announced on its own day, the year it is announced there is no public holiday on this date. Analogously, if the holiday is cancelled on its own day, there is still the holiday this year (so people do not have to go to work after listening to morning radio programs).nnAlso recall, that the day of February 29 exists only in leap years, that is, years that are divisible by 4, except those divisible by 100, except those divisible by 400. For example, years 1996, 2000 and 2004 are leap, while 1999 or 2100 are not.nnnInputnnInput contains multiple test cases. The first line of the input is a single integer T (1 <= T <= 30) which is the number of test cases. Then T test cases follow, each preceded by a single blank line.nnIn each case, the first line contains Ys and Yf (1800 <= Ys <= Yf <= 2200, Yf - Ys <= 100). Next line contains n - the number of records in the document (1 <= n <= 100). Next n lines contain the the document records, one on a line. See sample input for more detailed information.nnYou must not consider any other holidays except those explicitly specified in the document. You may assume that no holiday is removed before it is announced.nnnOutputnnOn the first line of each case print the maximal number of public holidays for the given period. After that print n lines - the version of the document with years inserted that provides the specified number of holidays. Adhere to the format of the sample output.nnTwo consecutive cases should be separated by a single blank line. No blank line should be produced after the last test case.nnIf it is impossible to interpret the document in the specified way, print -1 on the first and the only line of the output file.nnnSample Inputnn2nn1900 1999n9nJanuary 1, added January 1nJanuary 1, added January 7nFebruary 29, added February 29nNovember 7, added November 7nNovember 7, removed January 7nSeptember 1, added May 1nAugust 21, removed November 7nSeptember 1, added June 12nSeptember 1, added December 12nn1900 1900n2nMay 1, added May 1nApril 1, removed May 1nnSample Outputnn406nJanuary 1 1900, added January 1nJanuary 1 1901, added January 7nFebruary 29 1904, added February 29nNovember 7 1904, added November 7nNovember 7 1905, removed January 7nSeptember 1 1906, added May 1nAugust 21 1907, removed November 7nSeptember 1 1907, added June 12nSeptember 1 1908, added December 12nn-1

没有更多推荐了,返回首页