結果

問題 No.1036 Make One With GCD 2
ユーザー vjudge1
提出日時 2024-10-14 19:36:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 2,501 ms
コンパイル使用メモリ 156,756 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-10-14 19:36:58
合計ジャッジ時間 6,261 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 11 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

namespace mci {
    int n,q;
    array<int,500010> a;
    int main () {
        cin>> n;
        int rs=0;
        for (int i=1;i<=n;i++) {
            cin>> a[i];
        	rs+=a[i]==1;
		}
        int pr=0;
        for (int i=1;i<n;i++)
        	if (__gcd (a[i],a[i+1])==1) {
        		rs+=(i-pr)*(n-i);
        		pr=i;
			}
		cout<< rs;
		return 0;
    }
}

int main () {
    ios::sync_with_stdio (0);
    cin.tie (0);
    cout.tie (0);
    return mci::main ();
}
0