結果
| 問題 |
No.118 門松列(2)
|
| ユーザー |
srup٩(๑`н´๑)۶
|
| 提出日時 | 2016-09-16 15:18:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 5,000 ms |
| コード長 | 699 bytes |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 54,524 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 07:17:22 |
| 合計ジャッジ時間 | 1,444 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
int n, a[100010];
const int mod = 1e9 + 7;
ll conbination(int x){
ll ret = x * (x - 1) * (x - 2) / 6;
return ret;
}
int main(void){
cin >> n;
rep(i, n) cin >> a[i];
int cnt[110];
rep(i, 110) cnt[i] = 0;
rep(i, n){
cnt[a[i]]++;
}
ll ans = 0;
for (int i = 1; i <= 100; ++i){
for (int j = i + 1; j <= 100; ++j){
for (int k = j + 1; k <= 100; ++k){
if(cnt[i] != 0 && cnt[j] != 0 && cnt[k] != 0){//すべての長さの竹があるとき
(ans += conbination(3) * cnt[i] * cnt[j] * cnt[k]) %= mod;
}
}
}
}
printf("%lld\n", ans);
return 0;
}
srup٩(๑`н´๑)۶