結果

問題 No.1146 土偶Ⅰ
ユーザー Kome_soudouKome_soudou
提出日時 2022-11-09 02:09:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 174,168 KB
実行使用メモリ 12,196 KB
最終ジャッジ日時 2023-09-29 15:14:39
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 9 ms
4,468 KB
testcase_04 AC 64 ms
11,556 KB
testcase_05 AC 12 ms
4,528 KB
testcase_06 AC 31 ms
7,312 KB
testcase_07 AC 51 ms
9,748 KB
testcase_08 AC 64 ms
11,700 KB
testcase_09 AC 19 ms
5,696 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 27 ms
6,740 KB
testcase_12 AC 68 ms
12,196 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 20 ms
5,768 KB
testcase_15 AC 51 ms
9,432 KB
testcase_16 AC 25 ms
6,160 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 20 ms
5,908 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template <typename T> T gcd(T a, T b)
{
	if(a % b == 0) return b;
	else return gcd(b, a % b);
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	set<tuple<int, int, int>> st;
	for(int i = 0; i < n; i++)
	{
		for(int j = i + 1; j < n; j++)
		{
			for(int k = j + 1; k < n; k++)
			{
				if(gcd(gcd(a[i], a[j]), a[k]) == 1)
				{
					st.insert(make_tuple(a[i], a[j], a[k]));
				}
			}
		}
	}
	
	cout << (int)st.size() << endl;
	return 0;
}
0