結果
| 問題 |
No.917 Make One With GCD
|
| コンテスト | |
| ユーザー |
gyouzasushi
|
| 提出日時 | 2019-10-26 02:33:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,277 bytes |
| コンパイル時間 | 2,421 ms |
| コンパイル使用メモリ | 162,464 KB |
| 最終ジャッジ日時 | 2024-11-14 21:47:55 |
| 合計ジャッジ時間 | 2,783 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:21:1: error: ‘make_vec’ function uses ‘auto’ type specifier without trailing return type
21 | auto make_vec(size_t a, Ts... ts){
| ^~~~
main.cpp:21:1: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int gcd (int x,int y) {
if (x < y) swap(x, y);
if (y == 0) return x;
return gcd(x % y, y);
}
int main() {
int n;
cin>>n;
vector<int> a(n);
rep(i,n) cin>>a[i];
vector<map<int,ll>> dp(n);
rep(i,n) dp[i][a[i]]=1;
rep(i,n) {
rep(j,i) {
for(auto p:dp[j]) {
dp[i][gcd(p.first,a[i])]+=p.second;
}
}
}
ll ans=0;
rep(i,n) {
//for(auto p:dp[i]) cout<<"dp["<<i<<"]["<<p.first<<"]:"<<p.second<<endl;
ans+=dp[i][1];
}
cout<<ans<<endl;
}
gyouzasushi