結果
問題 |
No.118 門松列(2)
|
ユーザー |
![]() |
提出日時 | 2019-07-28 13:49:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 528 bytes |
コンパイル時間 | 682 ms |
コンパイル使用メモリ | 73,472 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 15:01:48 |
合計ジャッジ時間 | 1,756 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int MOD = (int)1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); for (int &ai: a) cin >> ai; vector<long long> cnt(101); for (int ai: a) cnt[ai]++; long long acc1 = 0, acc2 = 0, acc3 = 0; for (auto ci: cnt) { acc1 += ci; acc2 += ci * ci; acc3 += ci * ci * ci; } long long ans = (acc1 * (acc1 * acc1 - acc2 * 3) + acc3 * 2) / 6; cout << ans % MOD << endl; return 0; }