fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
Codeforces Round 1044-A (Div. 2) Redstone?
최초 업로드: 2025-09-11 17:57:07
최근 수정 시간: 2025-09-11 17:57:07
게시자: rlatjwls3333
카테고리: Codeforces
조회수: 18
# A. Redstone? [문제 링크](https://codeforces.com/contest/2133/problem/A) ## Problem Statement Steve stumbled upon a collection of $n$ gears, where gear $i$ has $a_i$ teeth, and he wants to arrange them into a row. After he arranges them, Steve will spin the leftmost gear at a speed of $1$ revolution per second. For each of the other gears, let $x$ be the number of teeth it has, $y$ be the number of teeth of the gear to its left, and $z$ be the speed the gear to its left spins at. Then, its speed will be $\frac{y}{x} \cdot z$ revolutions per second. Steve considers the contraption *satisfactory* if the rightmost gear spins at a speed of $1$ revolution per second. Determine whether Steve can rearrange the gears into a satisfactory contraption. ## Input Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows. The first line of each test case contains a single integer $n$ ($2 \le n \le 100$) — the number of gears Steve has. The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($2 \le a_i \le 100$) — the number of teeth of each gear. ## Output For each test case, print `"YES"` if Steve can rearrange the gears in a satisfactory way, and `"NO"` otherwise. You can output the answer in any case (upper or lower). For example, the strings `"yEs"`, `"yes"`, `"Yes"`, and `"YES"` will be recognized as positive responses. ## 풀이 가운데 있는 수들은 곱해서 전부 사라질 예정이므로 하나의 수가 두 번 이상 등장하는지 확인하면 된다. ``` c++ #include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while(t--) { int n; cin >> n; map<int, int> m; bool chk=false; while(n--) { int a; cin >> a; if(++m[a]==2) { chk=true; } } cout << (chk ? "YES\n" : "NO\n"); } } ```