Submission #10045073
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #define rep(i,n) for(int i=0;i<n;++i) #define rep1(i,n) for(int i=1;i<=n;++i) using namespace std; typedef long long ll; const ll MOD=1e+9+7; struct mint{ ll x; mint(ll x=0):x(x%MOD){} mint& operator+=(const mint a){ if((x+=a.x)>=MOD) x-=MOD; return *this; } mint& operator-=(const mint a){ if((x += MOD-a.x)>=MOD) x-=MOD; return *this; } mint& operator*=(const mint a){ (x*=a.x)%=MOD; return *this; } mint operator+(const mint a) const{ mint res(*this); return res+=a; } mint operator-(const mint a) const{ mint res(*this); return res-=a; } mint operator*(const mint a) const{ mint res(*this); return res*=a; } mint pow(ll t) const{ if(!t) return 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 res(*this); return res/=a; } }; int main() { int t; cin >> t; vector<int> a(t); rep(i,t){ cin >> a[i]; } vector<vector<mint>> dp(t+1,vector<mint>(601)); rep(i,t){ rep(j,a[i]+1){ dp[i][j].x = 1; } } rep1(i,t-1){ rep1(j,601){ rep(k,a[i]+1){ if(j%2==0){ dp[i][j/2+k] += dp[i-1][j]; } } } } mint res; rep(i,t){ res += dp[i][1]; } int x = 2; while(x<=600){ res += dp[t-1][x]; x *= 2; } cout << res.x << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Union |
User | kkktym |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1669 Byte |
Status | AC |
Exec Time | 87 ms |
Memory | 1664 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 5 ms | 768 KB |
07.txt | AC | 5 ms | 640 KB |
08.txt | AC | 5 ms | 768 KB |
09.txt | AC | 5 ms | 768 KB |
10.txt | AC | 5 ms | 768 KB |
11.txt | AC | 35 ms | 1664 KB |
12.txt | AC | 36 ms | 1664 KB |
13.txt | AC | 35 ms | 1664 KB |
14.txt | AC | 34 ms | 1664 KB |
15.txt | AC | 35 ms | 1664 KB |
16.txt | AC | 85 ms | 1664 KB |
17.txt | AC | 85 ms | 1664 KB |
18.txt | AC | 86 ms | 1664 KB |
19.txt | AC | 84 ms | 1664 KB |
20.txt | AC | 87 ms | 1664 KB |
21.txt | AC | 87 ms | 1664 KB |
22.txt | AC | 85 ms | 1664 KB |
23.txt | AC | 87 ms | 1664 KB |
24.txt | AC | 85 ms | 1664 KB |
25.txt | AC | 86 ms | 1664 KB |
26.txt | AC | 86 ms | 1664 KB |
27.txt | AC | 2 ms | 640 KB |
28.txt | AC | 1 ms | 512 KB |
29.txt | AC | 2 ms | 768 KB |
30.txt | AC | 2 ms | 768 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 3 ms | 256 KB |