fragment-header
fragment-markdown
홈
로그인
로그아웃
내 블로그
설정
로그인
Codeforces Round 1019-A (Div. 2) (C++) Common Multiple
최초 업로드: 2025-04-21 16:47:18
최근 수정 시간: 2025-08-30 14:08:06
게시자: rlatjwls3333
카테고리: Codeforces
조회수: 8
# A. Common Multiple [문제 링크](https://codeforces.com/contest/2103/problem/A) ## Problem Statement You are given an array of integers $a_1, a_2, \ldots, a_n$. An array $x_1, x_2, \ldots, x_m$ is *beautiful* if there exists an array $y_1, y_2, \ldots, y_m$ such that the elements of $y$ are distinct (in other words, $y_i \ne y_j$ for all $1 \le i < j \le m$), and the product of $x_i$ and $y_i$ is the same for all $1 \le i \le m$ (in other words, $x_i \cdot y_i = x_j \cdot y_j$ for all $1 \le i < j \le m$). Your task is to determine the maximum size of a subsequence (∗) of array $a$ that is beautiful. ## Input Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows. The first line of each test case contains a single integer $n$ ($1 \le n \le 100$) — the length of the array $a$. The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le n$) — the elements of array $a$. Note that there are **no** constraints on the sum of $n$ over all test cases. ## Output For each test case, output the maximum size of a subsequence of array $a$ that is beautiful. ## Footnotes (∗) A sequence $b$ is a subsequence of a sequence $a$ if $b$ can be obtained from $a$ by the deletion of several (possibly, zero or all) elements from arbitrary positions. ## 풀이 #### 서로 다른 정수의 수를 출력하면 된다. ``` 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; set<int> s; while(n--) { int a; cin >> a; s.insert(a); } cout << s.size() << '\n'; } } ```