結果

問題 No.1036 Make One With GCD 2
ユーザー firiexpfiriexp
提出日時 2020-04-25 17:31:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 888 bytes
コンパイル時間 3,164 ms
コンパイル使用メモリ 157,596 KB
最終ジャッジ日時 2025-01-10 01:20:48
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40 TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     for (auto &&k : v) scanf("%lld", &k);
      |                        ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;



static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&k : v) scanf("%lld", &k);
    ll ans = 0;
    using M = gp_hash_table<ll, ll>;
    vector<M> X(2);
    for (int i = 0; i < n; ++i) {
        int now = i&1, nxt = now^1;
        X[now].clear();
        for (auto &&j : X[nxt]) {
            X[now][__gcd(j.first, v[i])] += j.second;
        }
        X[now][v[i]]++;
        ans += X[now][1];
    }
    cout << ans << "\n";
    return 0;
}
0