結果
問題 | No.118 門松列(2) |
ユーザー |
![]() |
提出日時 | 2015-09-04 09:52:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 5,000 ms |
コード長 | 3,313 bytes |
コンパイル時間 | 1,613 ms |
コンパイル使用メモリ | 161,848 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 07:08:39 |
合計ジャッジ時間 | 2,660 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; #define FOR(i,a,b) for(int (i)=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define RANGE(vec) (vec).begin(),(vec).end() using namespace std; class ModInt { long long value_; public: static long long Mod; static void set_mod(long long mod) { Mod= mod; } static long long get_mod(void) { return Mod; } ModInt() : value_(0) {} ModInt(long long val) { if (val >= Mod) value_ = val % Mod; else if (val >= 0) value_ = val; else // val < 0 value_ = (((-val)/Mod+1)*Mod+val) % Mod; assert(value_ < Mod); } ModInt(const ModInt &other) { value_ = other.value_; } ~ModInt() {} #define OPT(OP) \ ModInt operator OP (const ModInt &other) const { \ return ModInt(value_ OP other.value_); \ } \ template<class T> \ ModInt &operator OP##=(const T &other) { \ return (*this = (*this OP ModInt(other))); \ } OPT(+) OPT(-) OPT(*) #undef OPT bool operator==(const ModInt &other) const { return (value_ == other.value_); } bool operator!=(const ModInt &other) const { return !(*this == other); } ModInt &operator=(const ModInt &other) { value_ = other.value_; return *this; } // cast overload operator int() const { return value_; } operator long long() const { return value_; } static long long pow(ModInt a, int k) { ModInt b = 1; while (k > 0) { if (k & 1) b = (b*a); a = (a*a); k >>= 1; } return b; } // call when Mod is prime ModInt inv() { return ModInt::pow(*this, Mod-2); } long long value() const { return value_; } friend std::ostream& operator<<(std::ostream& os, const ModInt& m) { os<<m.value_; return os; } }; // 互換性サポートは int, long long のみ #define OPT(OP,T) \ ModInt operator OP (const ModInt &a, T b) { return a OP ModInt(b); } \ ModInt operator OP (T a, const ModInt &b) { return ModInt(a) OP b; } OPT(*,int) OPT(+,int) OPT(-,int) OPT(*,long long) OPT(+,long long) OPT(-,long long) #undef OPT long long ModInt::Mod = (long long)(1E+9)+7; class PineDecorationSequence2 { public: void solve(void) { int N; cin>>N; vector<int> cntA(101,0); REP(i,N) { int a; cin>>a; ++cntA[a]; } ModInt all = 0; REP(i,101) FOR(j,i+1,101) FOR(k,j+1,101) all += ModInt(cntA[i])*cntA[j]*cntA[k]; cout<<all<<endl; } }; #if 1 int main(int argc, char *argv[]) { ios::sync_with_stdio(false); auto obj = new PineDecorationSequence2(); obj->solve(); delete obj; return 0; } #endif