- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >>n;
- vector<int> cards(n);
- // 紀錄各張牌的數量
- vector<int> cardsCounter(53, 0);
- for (int i = 0; i < n; i++)
- {
- cin >> cards[i];
- // 計算各張牌的數量
- ++cardsCounter[cards[i]];
- }
- // 找到數量最多和最少的牌(同花色)
- int maxCount = 0;
- int minCount = 1000;
- for (int i = 1; i <= 52; i++)
- {
- if (cardsCounter[i] > maxCount)
- {
- maxCount = cardsCounter[i];
- }
- if (cardsCounter[i] < minCount)
- {
- minCount = cardsCounter[i];
- }
- }
- // minCount 是數量最少的花色的牌數,表示最少有 minCount 副牌
- // 要湊成完整的牌至少要 maxCount 副牌,總共會有 maxCount * 52 張
- // 還需要補的牌數量為 maxCount * 52 - n
- cout << minCount << " " << (maxCount * 52) - n << endl;
- }
- /*
- 10
- 1 2 3 4 5 6 7 8 9 10
- 輸出
- 0 42
- */
複製代碼 回復 1# may |