結果
問題 |
No.917 Make One With GCD
|
ユーザー |
|
提出日時 | 2020-04-12 15:51:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 636 bytes |
コンパイル時間 | 1,893 ms |
コンパイル使用メモリ | 180,300 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 11:15:24 |
合計ジャッジ時間 | 2,747 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); i ++) using namespace std; typedef long long ll; typedef pair<ll,ll> PL; typedef pair<int,int> P; const int INF = 1e9; const ll MOD = 1e9 + 7; const vector<int> dy = {-1,0,1,0}; const vector<int> dx = {0,1,0,-1}; int main() { int n; cin >> n; vector<int> a(n); rep(i,n) cin >> a[i]; map<int,ll> dp; for (int x:a) { map<int,ll> now; now[x] = 1; for (auto p:dp) { now[p.first] += p.second; now[__gcd(x,p.first)] += p.second; } dp = now; } cout << dp[1] << endl; return 0; }