B. Dice Tower---------- 사유

7139 단어 사유Codeforces
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]);
	}

}

좋은 웹페이지 즐겨찾기