Codeforces Global Round 6 B - Dice Tower(简单数学)

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
题意:正方体可以向题目说的那样叠放,问有没有一种叠放方案能够满足看得见的面的数字之和位x
思路:我们枚举一下最上面的数字i(i为1到6),如果x-i是14的倍数(至于为什么是这个结论,可以自己尝试推一波?),那么就是了,小于21的时候特判一下。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,sum,t;
int main()
{
	int T,flag;
	scanf("%d",&T);
	while(T--)
	{
		flag=0;
		scanf("%lld",&x);
		if(x<=21)
		{
			printf("%s\n",(x>=15&&x<=20)?"YES":"NO");
			continue;
		}
		for(int j=1;j<=6;++j)
		if((x-j)%14==0) {
			flag=1;break;
		}
		printf("%s\n",(flag)?"YES":"NO");
	}
}
发布了70 篇原创文章 · 获赞 0 · 访问量 2454

猜你喜欢

转载自blog.csdn.net/qq_42479630/article/details/104128076
今日推荐