結果

問題 No.1036 Make One With GCD 2
ユーザー 👑 kmjpkmjp
提出日時 2020-05-01 23:30:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 965 bytes
コンパイル時間 2,477 ms
コンパイル使用メモリ 153,212 KB
実行使用メモリ 7,452 KB
最終ジャッジ日時 2023-08-26 16:06:57
合計ジャッジ時間 15,700 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
7,268 KB
testcase_01 AC 141 ms
7,320 KB
testcase_02 AC 118 ms
7,312 KB
testcase_03 AC 21 ms
4,804 KB
testcase_04 AC 36 ms
5,916 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 50 ms
5,072 KB
testcase_08 AC 39 ms
4,764 KB
testcase_09 AC 284 ms
7,364 KB
testcase_10 AC 259 ms
6,932 KB
testcase_11 AC 293 ms
7,268 KB
testcase_12 AC 278 ms
7,076 KB
testcase_13 AC 424 ms
7,112 KB
testcase_14 AC 437 ms
7,392 KB
testcase_15 AC 404 ms
6,892 KB
testcase_16 AC 400 ms
6,928 KB
testcase_17 AC 421 ms
7,156 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 401 ms
7,144 KB
testcase_23 AC 293 ms
5,988 KB
testcase_24 AC 431 ms
7,020 KB
testcase_25 AC 385 ms
6,736 KB
testcase_26 AC 392 ms
6,908 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 TLE -
testcase_39 AC 148 ms
7,340 KB
testcase_40 AC 297 ms
5,928 KB
testcase_41 AC 167 ms
7,320 KB
testcase_42 AC 168 ms
7,300 KB
testcase_43 AC 161 ms
7,452 KB
testcase_44 AC 169 ms
7,276 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];
map<ll,int> M,M2;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll ret=0;
	FOR(i,N) {
		cin>>A[i];
		
		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);
		M2.clear();
	}
	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