CF GYM 100548 Built with Qinghuai and Ari Factor(2014ACM西安現場賽Problem A)

版權聲明:本文爲博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/wujy47/article/details/43085185

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;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章