CF GYM 100548 Built with Qinghuai and Ari Factor(2014ACM亚洲区域赛西安站现场赛)

                      ProblemA. Built with Qinghuai and Ari Factor

Description

DISCLAIMER: Allnames, incidents, characters and places appearing in this problem arefictitious. Any resemblance to actual events or locales or realpersons, living or dead, is purely coincidental.

Shamatisan is asomewhat famous smartphone maker in China, they built smartphonesthat hope to contend with Abble and Dami for the hearts, minds andthe wallets of China’s consumers. They have a famous advertisingword, saying that Shamatisan phones are built with Qinghuai (aconcept which is hard to explain in English). Their latest phone T-1has just began taking reservations recently, or to be precious, atthe beginning of this month. But those who are tracking its progresson Aripapapa’s online store Skyat noticed an interesting fact thathas led to an apology by the online shopping site.

Those (being likesleuths in this story) who are always curious about questions like“In how many attoseconds1 were the Dami phones sold out?” foundsomething unusual about the reservation count of Shamatisan T-1. Italways has a divisor three! What’s the logic behind this mystery? Abit of digging into the site coding showed that the number ofreservations had been multipled by three. After this discovery,people started rumors like “Three is the Qinghuai factor, appliedbroadly by Shamatisan internally.” and began to call integers,which are divisible by three, Qinghuai numbers. They also defined ifall elements in a sequence are Qinghuai numbers, the sequence itselfis said to be built with Qinghuai. Moreover, after some research,people found that there is a feature called “Buy Buy Buy Ring” onSkyat, causing all reservation counts multiplied by a factor(possibly 1). The rumor “Any real number can be represented as anAripapapa Factor (also known as Ari Factor)” had been spreadwidely.

Later, anAripapapa’s spokeswoman said this was an incident and posted anofficial apology announcement. It is said that a programmer “made ahighly unscientific decision”. As a result, main programmer ofSkyat whose name is Beiguoxia lost his job.

Our protagonistPike loves to write programs that are able to automatically grab somedata from Internet. As you may already know, such programs areusually called “spider”.

Pike has alreadycollected some sequence using his spider. Now he wonders that ifthese sequences are built with Qinghuai. Help Pike to figure outthis!

Input

The first line ofthe input gives the number of test cases, T. T test cases follow.

For each test case,the first line contains an integer n (1 ≤ n ≤ 100), the length ofsequence S. The second line contains n integers, which represent nintegers in sequence S.

All the numbers inthe input will not exceed 106. 11 attosecond equals to 10−18seconds.

Output

For each test caseoutput one line “Case #x: y”, where x is the case number(starting from 1) and y is “Yes” (without quotes) if the sequenceS is built with so-called “Qinghuai”, otherwise “No” (withoutquotes).

Samples

Sample Input

Sample Output

2

3

1 2 3

2

3000 996

Case #1: No

Case #2: Yes

Hints

In the first case,since the sequence contains numbers which are too small to haveQinghuai, it cannot be called being built with Qinghuai.

In the second case,the first integer is the signage of Shamatisan, and the secondinteger represents core values of Aripapapa, we can declare that thesequence is built with Qinghuai.

Also note that thewhole problem statement (including hints) had deliberately beenwritten as a joke, don’t be so serious!

题意及思路:

这道题题目非常长,但是这道题目其实是非常水的,在题目中已经加粗和下划线出关键词,意思就是要输入的数据都能够被3整除,那么就输出Yes,反之,就输出No。

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t,tmp;
	cin>>t;//输入测试用例的个数 
	for(int i=1;i<=t;i++)
	{
		int flag=1;
		cin>>n;//输入每个测试用例中的数字个数 
		for(int j=1;j<=n;j++)
		{
			cin>>tmp;//输入每一个数 
			if(tmp%3)//如果有不能被3整除,那么flag=false了 
				flag=0;
		}
		cout<<"Case #"<<i<<": ";
		if(flag)cout<<"Yes\n";//如果输入的数都能够被3整除,输出Yes 
		else cout<<"No\n";
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/rnzhiw/article/details/81702329