結果
| 問題 |
No.917 Make One With GCD
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-17 00:59:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 814 bytes |
| コンパイル時間 | 1,563 ms |
| コンパイル使用メモリ | 179,056 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 16:30:02 |
| 合計ジャッジ時間 | 2,511 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using lint = long long;
#define endl '\n'
lint const mod = 1e9+7;
//long const mod = 998244353;
long long gcd(long long a,long long b){
if(a<b)swap(a,b);
if(a%b==0)return b;
else return gcd(b,a%b);
}
long long gcd(long long a,long long b,long long c){
return gcd(a,gcd(b,c));
}
long long lcm(long long a, long long b){
return (a / gcd(a,b)) * b;
}
int main(){
int n;
cin >> n;
lint y[n];
for(int i=0;i<n;i++)cin >> y[i];
vector<map<lint,lint>>dp(n+1);
for(int i=0;i<n;i++){
dp[i+1][y[i]]++;
for(auto x: dp[i]){
dp[i+1][x.first] += x.second;
dp[i+1][gcd(x.first, y[i])] += x.second;
}
}
cout << dp[n][1] << endl;
}