結果

問題 No.1036 Make One With GCD 2
ユーザー pekempey
提出日時 2020-04-24 21:33:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 585 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 204,496 KB
最終ジャッジ日時 2025-01-09 23:16:52
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N); rep(i, N) cin >> A[i];
    map<ll, ll> dp;
    ll ans = 0;
    rep(i, N) {
        map<ll, ll> ep;
        for (auto [k, v] : dp) {
            ep[gcd(k, A[i])] += v;
        }
        ep[A[i]]++;
        dp = ep;
        ans += dp[1];
    }
    cout << ans << endl;
}
0