結果
問題 |
No.1238 選抜クラス
|
ユーザー |
|
提出日時 | 2021-05-08 18:57:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 2,276 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 104,660 KB |
実行使用メモリ | 27,392 KB |
最終ジャッジ日時 | 2024-09-17 00:44:11 |
合計ジャッジ時間 | 2,754 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
//#include <atcoder/all> #include <iostream> #include <numeric> #include <cmath> #include <limits> #include <stdio.h> #include <iomanip> #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower using namespace std; //using namespace atcoder; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector<ll>; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector<vector<pair<ll, ll>>>; class quo{ public: ll de; ll nu; ll gcd(ll a,ll b){ ll c = a; while (a % b != 0) { c = a % b; a = b; b = c; } return b; } quo re(){ quo res; ll g=gcd(this->de,this->nu); res.de=this->de/g; res.nu=this->nu/g; return res; } quo operator +(const quo &a){ quo c; c.nu=this->nu*a.nu; c.de=this->nu*a.de+this->de*a.nu; return c.re(); } quo operator -(const quo &a){ quo c; c.nu=this->nu*a.nu; c.de=-this->nu*a.de+this->de*a.nu; return c.re(); } quo operator *(const quo &a){ quo c; c.nu=this->nu*a.nu; c.de=this->de*a.de; return c.re(); } }; int main(){ ll mod=1e9+7; ll N,K; cin>>N>>K; vll A(N); rep(i,N){ cin>>A[i]; A[i]-=K; } vector<vll> DP(N+1,vll(30000,0)); DP[0][15000]=1; rep(i,N){ rep(j,30000){ if(DP[i][j]!=0){ DP[i+1][j]+=DP[i][j]; DP[i+1][j]%=mod; DP[i+1][j+A[i]]+=DP[i][j]; DP[i+1][j+A[i]]%=mod; } } } ll an=mod-1; for(ll i=15000;i<30000;i++){ an+=DP[N][i]; } cout<<an%mod<<endl; }