CF1868B1 Candy Party (Easy Version)
题目描述
有 $n$ 个人,第 $i$ 个人有 $a_i$ 颗糖,在派对上,每个人 **会且仅会做下面的事情恰好一次** :
- 选一个正整数 $p\ (\ 1 \leq p \leq n\ )$ 和一个非负整数 $x$ ,然后把 $2^x$ 颗糖给第 $p$ 个人。注意任意时刻一个人手上的糖不能变成负数,并且一个人不能把糖给自己。
你需要回答能否在上述操作后让每个人手中的糖果数量相同。
注意本题和 Hard Version 不同的是本题中每个人必须从他人处接受恰好一次糖果,给出恰好一次糖果。
输入格式
**本题有多组数据**。
第一行一个整数 $t\ (1 \leq t \leq 1000)$ ,表示数据组数。
对于每组数据:
第一行一个整数 $n\ (1 \leq n \leq 2\ ·10^5)$ 。
接下来一行 $n$ 个整数,表示$a_i\ (1 \leq a_i \leq 10^9)$。
保证对于所有数据,$\sum n \leq 2\ ·10^5$ 。
输出格式
对于每组数据输出一行, "Yes" 代表存在一种方案满足要求,否则输出 "No" 。
对大小写不敏感。
说明/提示
In the first test case:
- The first person gives $ 1 $ candy to the third person;
- The second person gives $ 2 $ candies to the first person;
- The third person gives $ 1 $ candy to the second person.
Then all people have $ 3 $ candies.
In the second test case:
- The fifth person gives $ 4 $ candies to the first person, from now on the first person has $ 5 $ candies;
- The first person gives $ 2 $ candies to the third person;
- The third person gives $ 2 $ candies to the fifth person;
- The fourth person gives $ 2 $ candies to the second person;
- The second person gives $ 1 $ candy to the fourth person.
Then all people have $ 3 $ candies. Note that at first the first person cannot give $ 2 $ candies to the third person, since he only has $ a_1=1 $ candy. But after the fifth person gives him $ 4 $ candies, he can do this, because he currently has $ 1+4=5 $ candies.
In the third test case, it's impossible for all people to have the same number of candies.
In the fourth test case, the first person gives $ 1024 $ candies to the second person, and the second person gives $ 1024 $ candies to the first person as well.