#45594: cpp ac


1121232@stu.wghs.tp.edu.tw (Ian911436)

學校 : 臺北市私立薇閣高級中學
編號 : 258883
來源 : [60.248.154.143]
最後登入時間 :
2025-05-14 15:36:23
j224. 寶可夢圖鑑 -- 板橋高中教學題 | From: [60.248.154.143] | 發表日期 : 2025-03-21 09:42

#include <bits/stdc++.h>>

using namespace std;

int main() {
    int n; 
    cin >> n;

    vector<int> p; // p 存儲寶可夢編號
    for (int i = 0; i < n; i++) {
        int q; // q 為當前輸入的寶可夢編號
        cin >> q;

        // 檢查 p 中是否有相同的寶可夢編號
        if (find(p.begin(), p.end(), q) == p.end()) {
            p.push_back(q); // 如果沒有相同的才加入 vector
        }
    }

    cout << p.size() << endl; // 輸出不同寶可夢的數量

    return 0;
}

 
ZeroJudge Forum