結果
| 問題 |
No.917 Make One With GCD
|
| コンテスト | |
| ユーザー |
tko919
|
| 提出日時 | 2019-10-26 17:38:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,002 bytes |
| コンパイル時間 | 1,666 ms |
| コンパイル使用メモリ | 176,288 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 11:09:41 |
| 合計ジャッジ時間 | 2,699 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end
map<int,ll> dp[61];
ll gcd(ll a,ll b){return (b?gcd(b,a%b):a);}
int main(){
int n; scanf("%d",&n);
vector<int> a(n);
rep(i,0,n)scanf("%d",&a[i]);
dp[0][0]=1;
rep(i,0,n)for(P p:dp[i]){
ll g=p.first,val=p.second;
dp[i+1][g]+=dp[i][g];
dp[i+1][gcd(g,a[i])]+=dp[i][g];
}
printf("%lld\n",dp[n][1]);
return 0;
}
tko919