A. Holidays

A. Holidays

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

#include
#include
#include
#include
#include
using namespace std;
int Comp(const void*a, const void*b)
{
	return  *(int*)a - *(int*)b;
}
int max(int a, int b)
{
	if (a > b)
	{
		return a;
	}
	return b;
}
int main()
{
	int n;
	cin >> n;
	if (n <= 5 && n>=2)
	{
		cout << 0 << " " << 2;
	}
	else if (n < 2)
	{
		cout << 0 << " " << n;
	}
	else
	{
		if (n % 7 == 0)
		{
			cout << n / 7 * 2 << " " << n / 7 * 2;
		}
		else
		{
			int b = n % 7;
			if (b == 1)
			{
				cout << (n / 7) * 2 << " " << (n / 7) * 2 + 1;
			}
			else if (b > 1 && b <= 5)
			{
				cout << (n / 7) * 2 << " " << (n / 7) * 2 + 2;
			}
			else
			{
				cout << (n / 7) * 2 + 1 <<" "<< (n / 7) * 2 + 2;
			}
		}
	}
	return 0;
}

你可能感兴趣的:(算法)