結果
問題 | No.1731 Product of Subsequence |
ユーザー | 👑 platinum |
提出日時 | 2021-11-05 21:57:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,581 bytes |
コンパイル時間 | 3,132 ms |
コンパイル使用メモリ | 206,192 KB |
実行使用メモリ | 169,472 KB |
最終ジャッジ日時 | 2024-04-24 05:43:57 |
合計ジャッジ時間 | 10,728 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 723 ms
157,824 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 24 ms
8,448 KB |
testcase_09 | WA | - |
testcase_10 | AC | 927 ms
168,704 KB |
testcase_11 | AC | 798 ms
145,920 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 16 ms
7,296 KB |
testcase_14 | AC | 686 ms
128,384 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 646 ms
133,888 KB |
testcase_19 | AC | 17 ms
7,424 KB |
testcase_20 | AC | 519 ms
109,440 KB |
testcase_21 | AC | 910 ms
169,472 KB |
testcase_22 | AC | 4 ms
5,376 KB |
testcase_23 | WA | - |
testcase_24 | AC | 18 ms
7,296 KB |
testcase_25 | AC | 8 ms
5,376 KB |
testcase_26 | AC | 142 ms
32,384 KB |
testcase_27 | AC | 187 ms
41,728 KB |
testcase_28 | AC | 404 ms
79,616 KB |
testcase_29 | AC | 152 ms
34,304 KB |
testcase_30 | AC | 827 ms
167,936 KB |
testcase_31 | AC | 4 ms
5,376 KB |
testcase_32 | WA | - |
testcase_33 | AC | 4 ms
5,376 KB |
testcase_34 | AC | 57 ms
16,000 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair<int,int>; using vv = vector<vector<int>>; const int INF = (int)1e9; const LL LINF = (LL)1e18; long long const mod = 1000000007; struct mint{ long long val; mint(long long val = 0): val(val % mod) {} mint& operator += (const mint n){ val += n.val; if(val >= mod) val -= mod; return *this; } mint& operator -= (const mint n){ val -= n.val; if(val < 0) val += mod; return *this; } mint& operator *= (const mint n){ val *= n.val; val %= mod; if(val < 0) val += mod; return *this; } mint operator + (const mint n) const{ mint res(*this); return res += n; } mint operator - (const mint n) const{ mint res(*this); return res -= n; } mint operator * (const mint n) const{ mint res(*this); return res *= n; } mint pow(long long n) const{ if(n == 0) return 1; mint m = pow(n >> 1); m *= m; if(n & 1) m *= *this; return m; } // mint division for prime mod mint inv() const{ return pow(mod - 2); } mint& operator /= (const mint n){ return (*this) *= n.inv(); } mint operator / (const mint n) const{ mint res(*this); return res /= n; } }; int main(){ int N; LL K; cin >> N >> K; vector<LL> A(N); rep(i,N) cin >> A[i]; vector<map<LL,mint>> dp(N+1); dp[0][K] = 1; rep(i,N){ for(auto itr : dp[i]){ LL res = itr.first; mint cnt = itr.second; dp[i+1][res] += cnt; LL g = gcd(res, A[i]); dp[i+1][res / g] += cnt; } } cout << dp[N][1].val << endl; return 0; }