题解 模拟赛 【dice】

模拟赛 【dice】

题目大意:

image

solution:

贪心的想,每次让骰子上面为 \(5\)\(6\) 可以用最少次数使总和 \(\geq x\) 。然后分情况讨论就行了。

细节处理:

  • \(\text{long long}\) ;
  • 情况考虑周全。
代码
#include<cstdio>
using namespace std;
typedef long long LL;
int main(){
	LL x; scanf("%lld",&x);
	LL ans;
	if(x<=11){//小于11
		if(x<=6) puts("1");
		else 	 puts("2");
	}
	else{//大于11
		if(x%11==0)//如果能整除,说明5 6来回转正好凑成x
			ans=x/11*2;//11 是由 5 6组成,算转两次
		else {
			int r=x%11;//有余数情况
			if(r<=6) ans=x/11*2+1;//与小于11的讨论类似
			else	 ans=x/11*2+2;
		}
		printf("%lld\n",ans);
	}
	
	return 0;
}

End

posted @ 2021-08-09 10:43  Mr_think  阅读(41)  评论(0)    收藏  举报