結果
問題 |
No.917 Make One With GCD
|
ユーザー |
![]() |
提出日時 | 2020-10-30 01:11:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 383 bytes |
コンパイル時間 | 2,673 ms |
コンパイル使用メモリ | 206,456 KB |
最終ジャッジ日時 | 2025-01-15 16:25:05 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for(auto &e : a) cin >> e; map<int, long long> dp; dp[0] = 1; for(auto &x : a) { map<int, long long> np(dp); for(auto &[g, cnt] : dp) { np[gcd(g, x)] += dp[g]; } dp = np; } cout << dp[1] << '\n'; return 0; }