結果
| 問題 |
No.917 Make One With GCD
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-25 22:21:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 778 bytes |
| コンパイル時間 | 1,702 ms |
| コンパイル使用メモリ | 176,952 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 11:04:12 |
| 合計ジャッジ時間 | 2,620 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
if(a<b) swap(a,b);
if(a%b==0) return b;
else return gcd(a%b,b);
}
int main(){
ll i,j;
ll n;
cin>>n;
ll a[n];
for(i=0;i<n;i++) cin>>a[i];
map<ll,ll> ma,ma2;
ma[a[0]]=1;
for(i=1;i<n;i++){
ma2=ma;
for(auto it=ma.begin();it!=ma.end();++it){
ma2[gcd(it->first,a[i])]+=it->second;
}
ma2[a[i]]++;
ma=ma2;
}
cout<<ma[1]<<endl;
}