首页 > 其他分享 >CodeForces - 670A Holidays (模拟) 水

CodeForces - 670A Holidays (模拟) 水

时间:2023-06-08 14:02:12浏览次数:51  
标签:mm 670A year CodeForces Holidays int Mars Input include

Time Limit: 1000MS

 

Memory Limit: 262144KB

 

64bit IO Format: %I64d & %I64u

CodeForces - 670A


Holidays



Submit Status




Description




On the planet Mars a year lasts exactly n






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





Source



Codeforces Round #350 (Div. 2)



//题意:



给你一个数n,表示火星上一年的天数,火星上一年也是一周七天,五个工作日,两个节假日,问火星上一年最少休息几天,最多休息几天



//思路:



水题,直接模拟




#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int n,m,mm;
	int l,r,i,j;
	while(scanf("%d",&n)!=EOF)
	{
		if(n<2)
		{
			l=0;r=n;
		}
		else if(n<=5)
		{
			l=0;r=2;
		}
		else if(n<=7)
		{
			l=n-5;r=2;
		}
		else if(n>7)
		{
			m=n/7;
			m*=2;
			mm=n%7;
			if(mm<2)
			{
				l=m;r=m+mm;
			}
			else if(mm<=5)
			{
				l=m;r=m+2;
			}
			else if(mm<7)
			{
				l=m+mm-5;r=m+2;
			}
		}
		printf("%d %d\n",l,r);
	}
	return 0;
}





标签:mm,670A,year,CodeForces,Holidays,int,Mars,Input,include
From: https://blog.51cto.com/u_16079508/6439534

相关文章

  • Codeforces Round 876 (Div. 2) 题解 A - D
    A.TheGoodArray题目大意给定两个整数\(n\)和\(k\),规定一个\(01\)数列为好的的条件是,对于\(1\simn\)中任意的\(i\),都有:\(a\)的前\(i\)个元素中至少有\(\lceil\frac{i}k\rceil\)个都是\(1\)。\(a\)的后\(i\)个元素中至少有\(\lceil\frac{i}k\rceil\)个都是......
  • codeforces.com/contest/1553/problem/B
    简单字符串哈希题意给一个字符串s和t,问从s的某个位置开始,向右到某个点后再向左,顺序遍历到的字符形成的字符串可否为t。思路数据只有500,\(O(n^3)\)可过,枚举转折点,然后枚举开头和结尾。代码intn,m,k;ullHash[1010],rHash[1010],p[1010],rp[1010],sum;voidsolve(){ ......
  • Codeforces Round 876 (Div. 2) A-D
    比赛地址A.TheGoodArray题意:定义一个数组是good的要求有:从左往右所有的i,前i个数中至少有[i/k]个数是1从右往左所有的i,前i个数中至少有[i/k]个数是1问good数组对于n而言最少需要多少个1Solution先从左往右填1,直到满足第一个条件,然后从右往左填1,直到满足第二个条件voidso......
  • ACM-CodeForces-#685(Div.2)
    A.SubtractorDivide#include<iostream>usingnamespacestd;intmain(){ intT,n; cin>>T; while(T--) { cin>>n; if(n<=3) n--; else n=2+(n&1); cout<<n<<endl; } return0;}B.Non-SubstringSubsequence#in......
  • Codeforces 1566G - Four Vertices(线段树分治)
    交了整整2页,本来想用随机化卡过去的,后来发现我的实现跑得太慢就写正常做法了。首先发现最优答案对应的四个点只可能有以下两种可能:\(a,b\)间有边,\(c,d\)间有边,此时答案是\(a,b\)边权值加\(c,d\)边权值。\(a\)与\(b,c,d\)三个点间都有边,此时答案是三条边权值之和。......
  • Codeforces 1801D The way home
    看到shortestpaths来做的。首先有一个贪心的策略,对于当前点\(u\)若不能直接往后走则肯定是选择经过的点中\(w_i\)最大的加。很好理解,证明就不需要了。所以可以定义状态\(f_{u,mx}\)为\(u\)点最大能加的值为\(h_{mx}\)的最优状态,\(h\)是\(w\)离散化后的数组。......
  • Codeforces 1588F - Jumping Through the Array
    显然无法用polylog的数据结构维护,序列分块也不行,考虑询问分块。每\(B\)个询问处理一次。将这个询问中\(2,3\)操作涉及到的点设为“关键点”,那么容易发现,环上每一段以关键点结尾的链在这块操作的过程中始终保持不变,也就是说我们可以把它们缩在一起。先预处理出每个块的增量......
  • Codeforces 1495F - Squares
    不知道怎么放到div1F的,感觉没啥亮点。首先对于一条\(1\)到\(n+1\)的路径而言,它经过的点的编号一定是递增的,也就是说,如果我们将关键点大小排个序,那么答案就是相邻两点间最短路的和。删/加点造成的变化是\(O(1)\)的,所以问题等价于,多次询问这张图中\(x,y\)之间最短路的......
  • Codeforces Round 876 (Div. 2)
    PrefaceDP腐乳闪总出列!(本来以为大掉分的一把,但这个号因为挺新的所以竟然还能上挺多分的,压线完成了5场上紫)早知道去做E题了,感觉CF真得要看题目相性,有些题目就是一眼感觉不适合自己的说A.TheGoodArray一个要动点脑子的签到题,因为\(a_1,a_n\)必须等于\(1\),然后中间的\(n-1\)......
  • Codeforces Round 876 (Div. 2)题解
    CodeforcesRound876(Div.2)A.TheGoodArray标签greedymath题意对于任意\(i\in\{1,2,\dots,n\}\),要求数列\(a\)满足前\(i\)个元素中至少有\(\lceil\frac{i}{k}\rceil\)个元素为\(1\),后\(i\)个元素中至少有\(\lceil\frac{i}{k}\rceil\)个元素为\(1\)。思......