CF GYM 100548 Built with Qinghuai and Ari Factor(2014ACM西安现场赛Problem A)

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!



知识点:


水题。



解题思路:


当输入的n个数都能被3整除时,输出“Yes”;否则输出“No”



参考代码:

#include <iostream>
#include <cstdio>
using namespace std;

int cCase, nCase, n, x;

int main() {
    scanf("%d", &nCase);
    while (nCase--) {
        scanf("%d", &n);
        bool flag = true;
        for (int i = 0; i < n; i++) {
            scanf("%d", &x);
            if (x % 3 != 0) {
                flag = false;
            }
        }
        if (flag) {
            printf("Case #%d: Yes\n", ++cCase);
        } else {
            printf("Case #%d: No\n", ++cCase);
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值