結果

問題 No.1146 土偶Ⅰ
ユーザー kotatsugame
提出日時 2020-08-06 01:51:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 65,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-18 21:29:18
合計ジャッジ時間 1,495 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int A[100],N;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	int cnt=0;
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++)
	{
		int t=gcd(A[i],A[j]);
		for(int k=j+1;k<N;k++)if(gcd(t,A[k])==1)cnt++;
	}
	cout<<cnt<<endl;
}
0