結果
| 問題 |
No.1036 Make One With GCD 2
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-03-14 20:50:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 943 bytes |
| コンパイル時間 | 1,175 ms |
| コンパイル使用メモリ | 111,140 KB |
| 実行使用メモリ | 20,964 KB |
| 最終ジャッジ日時 | 2024-11-07 02:02:12 |
| 合計ジャッジ時間 | 9,307 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | TLE * 1 -- * 40 |
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
if(b==0) return a;
return gcd(b, a%b);
}
int main()
{
int n;
scanf("%d", &n);
vector<ll> a(n);
for(int i=0; i<n; i++){
scanf("%lld", &a[i]);
}
ll ans=0;
for(int i=0; i<n; i++){
if(a[i]==1){
ans+=n-i;
continue;
}
ll g=a[i];
for(int j=i+1; j<n; j++){
g=gcd(g, a[j]);
if(g==1){
ans+=n-j;
break;
}
}
}
printf("%lld\n", ans);
return 0;
}
chocorusk