結果
| 問題 |
No.1036 Make One With GCD 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-25 17:35:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 932 bytes |
| コンパイル時間 | 2,607 ms |
| コンパイル使用メモリ | 160,612 KB |
| 最終ジャッジ日時 | 2025-01-10 01:22:37 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 TLE * 18 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~
ソースコード
#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;
for (auto &&k : X[now]) {
k.second = 0;
}
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;
}