結果

問題 No.3024 等式
ユーザー kotatsugamekotatsugame
提出日時 2020-03-09 07:55:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,297 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 77,560 KB
実行使用メモリ 99,072 KB
最終ジャッジ日時 2024-04-25 10:10:22
合計ジャッジ時間 9,801 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
9,728 KB
testcase_01 AC 7 ms
9,600 KB
testcase_02 AC 7 ms
9,728 KB
testcase_03 AC 8 ms
9,728 KB
testcase_04 AC 7 ms
9,728 KB
testcase_05 AC 7 ms
9,728 KB
testcase_06 AC 12 ms
9,984 KB
testcase_07 AC 13 ms
10,112 KB
testcase_08 AC 15 ms
10,112 KB
testcase_09 AC 14 ms
10,240 KB
testcase_10 AC 15 ms
10,240 KB
testcase_11 AC 14 ms
10,240 KB
testcase_12 AC 254 ms
18,432 KB
testcase_13 AC 256 ms
18,176 KB
testcase_14 AC 383 ms
22,656 KB
testcase_15 AC 390 ms
23,296 KB
testcase_16 AC 333 ms
20,992 KB
testcase_17 AC 264 ms
18,944 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<set>
#include<vector>
using namespace std;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
pair<long,long>norm(long a,long b)
{
	long g=gcd(a,b);
	if(g!=1)a/=g,b/=g;
	if(b<0)a=-a,b=-b;
	return make_pair(a,b);
}
set<pair<long,long> >M[1<<17];
int N;
long A[7];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		M[1<<i].insert(norm(A[i],1));
	}
	for(int i=1;i+1<1<<N;i++)
	{
		if(__builtin_popcount(i)==1)continue;
		for(int x=i;;x=x-1&i)
		{
			for(int y=i&~x;;y=y-1&i&~x)
			{
				for(const pair<long,long>&X:M[x])
				{
					for(const pair<long,long>&Y:M[y])
					{
						M[i].insert(norm(X.first*Y.second+Y.first*X.second,X.second*Y.second));
						M[i].insert(norm(X.first*Y.second-Y.first*X.second,X.second*Y.second));
						M[i].insert(norm(-X.first*Y.second+Y.first*X.second,X.second*Y.second));
						M[i].insert(norm(X.first*Y.first,X.second*Y.second));
						M[i].insert(norm(X.first*Y.second,X.second*Y.first));
						M[i].insert(norm(Y.first*X.second,Y.second*X.first));
					}
				}
				if(y==0)break;
			}
			if(x==0)break;
		}
	}
	for(int i=1;i<1<<N;i++)for(int j=1;j<1<<N;j++)
	{
		if(i&j)continue;
		for(const pair<long,long>&X:M[i])
		{
			if(M[j].find(X)!=M[j].end())
			{
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
}
0