B. Dice Tower-------思维

Bob is playing with 6-sided dice. A net of such standard cube is shown below.

He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of each dice. Then he counts the number of visible pips on the faces of the dice.

For example, the number of visible pips on the tower below is 29 — the number visible on the top is 1, from the south 5 and 3, from the west 4 and 2, from the north 2 and 4 and from the east 3 and 5.

The one at the bottom and the two sixes by which the dice are touching are not visible, so they are not counted towards total.

Bob also has t favourite integers xi, and for every such integer his goal is to build such a tower that the number of visible pips is exactly xi. For each of Bob’s favourite integers determine whether it is possible to build a tower that has exactly that many visible pips.

Input
The first line contains a single integer t (1≤t≤1000) — the number of favourite integers of Bob.

The second line contains t space-separated integers xi (1≤xi≤1018) — Bob’s favourite integers.

Output
For each of Bob’s favourite integers, output “YES” if it is possible to build the tower, or “NO” otherwise (quotes for clarity).

Example
inputCopy

4
29 34 19 38
outputCopy
YES
YES
YES
NO
Note
The first example is mentioned in the problem statement.

In the second example, one can build the tower by flipping the top dice from the previous tower.

In the third example, one can use a single die that has 5 on top.

The fourth example is impossible.

题意:有n个筛子塔,给你一个数,问你把筛子堆起来,裸露在外的数字之和是否恰好为这个数。是输出YES 否输出NO

解析:对于只有一个筛子 1和6相互对应,5和2相互对应 4和3相互对应。它们都等于7,所以一个筛子总和为21.对于题目肯定有一面被挡住,那么值有可能是15,16,17,18,19.如果是一个筛子塔除了最上面的筛子被遮挡了一面,下面的都被遮挡了2面,那么就-7.所以枚举最上面的筛子是遮住了那一面,那剩下来的只要是14的倍数就行了。



#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[10]={15,16,17,18,19,20};
ll x;
int t;
ll res[1000005];
void slove(ll  x)
{
	if(x<15)
	{
		puts("NO");
		return ;
	}
	for(int i=0;i<6;i++)
	{
		if((x-a[i])%14==0)
		{
			puts("YES");
			return ;
		}
	}
	puts("NO");
}
int main()
{
	cin>>t;
	for(int i=0;i<t;i++) cin>>res[i];
	for(int i=0;i<t;i++)
	{
		slove(res[i]);
	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值