結果

問題 No.1336 Union on Blackboard
ユーザー どらら
提出日時 2021-01-15 21:50:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,655 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 167,840 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 14:09:06
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
static const long long mod = 1000000007;
struct mint {
long long x;
mint(ll x = 0):x(x%mod) {}
//mint(ll x = 0):x((x%mod+mod)%mod) {} // for minus
mint& operator+=(const mint a) {
(x += a.x) %= mod;
return *this;
}
mint& operator-=(const mint a) {
(x += mod-a.x) %= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint ret(*this);
return ret += a;
}
mint operator-(const mint a) const {
mint ret(*this);
return ret -= a;
}
mint operator*(const mint a) const {
mint ret(*this);
return ret *= a;
}
mint pow(ll t) const {
if(t==0) return mint(1);
mint a = pow(t>>1);
a *= a;
if(t&1) a *= *this;
return a;
}
//for prime mod
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint ret(*this);
return ret /= a;
}
};
ostream &operator<<(ostream& os, const mint& x) {
os << x.x;
return os;
}
void solve(){
int N;
cin >> N;
vector<int> v(N);
rep(i,N) cin >> v[i];
mint ret = v[0];
REP(i,1,N){
ret = (ret+v[i]) + (ret * v[i]);
}
cout << ret << endl;
}
int main(){
int t;
cin >> t;
rep(i,t){
solve();
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0