結果

問題 No.1036 Make One With GCD 2
ユーザー 👑 kmjpkmjp
提出日時 2020-04-24 23:24:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 965 bytes
コンパイル時間 2,026 ms
コンパイル使用メモリ 202,276 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-25 01:22:22
合計ジャッジ時間 14,107 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
7,552 KB
testcase_01 AC 152 ms
7,552 KB
testcase_02 AC 132 ms
7,552 KB
testcase_03 AC 23 ms
5,376 KB
testcase_04 AC 35 ms
5,888 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 49 ms
5,376 KB
testcase_08 AC 41 ms
5,376 KB
testcase_09 AC 290 ms
7,168 KB
testcase_10 AC 266 ms
7,168 KB
testcase_11 AC 290 ms
7,296 KB
testcase_12 AC 271 ms
7,040 KB
testcase_13 AC 448 ms
7,168 KB
testcase_14 AC 452 ms
7,296 KB
testcase_15 AC 431 ms
7,040 KB
testcase_16 AC 430 ms
6,912 KB
testcase_17 AC 438 ms
7,296 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 407 ms
6,912 KB
testcase_23 AC 301 ms
6,144 KB
testcase_24 AC 444 ms
7,296 KB
testcase_25 AC 410 ms
6,784 KB
testcase_26 AC 407 ms
7,040 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 TLE -
testcase_39 AC 153 ms
7,296 KB
testcase_40 AC 301 ms
6,016 KB
testcase_41 AC 181 ms
7,552 KB
testcase_42 AC 180 ms
7,552 KB
testcase_43 AC 176 ms
7,552 KB
testcase_44 AC 181 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[505050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	map<ll,ll> M;
	ll ret=0;
	FOR(i,N) {
		cin>>A[i];
		
		map<ll,ll> M2;
		M[A[i]]++;
		FORR(m,M) {
			ll x=__gcd(m.first,A[i]);
			if(x==1) ret+=m.second;
			M2[x]+=m.second;
		}
		swap(M,M2);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0