結果

問題 No.3024 等式
ユーザー kotatsugamekotatsugame
提出日時 2020-03-09 08:00:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,483 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 79,632 KB
実行使用メモリ 94,720 KB
最終ジャッジ日時 2024-04-25 10:10:34
合計ジャッジ時間 8,903 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 8 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 208 ms
14,080 KB
testcase_13 AC 206 ms
14,080 KB
testcase_14 AC 313 ms
19,456 KB
testcase_15 AC 325 ms
20,352 KB
testcase_16 AC 271 ms
17,280 KB
testcase_17 WA -
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;
	return make_pair(a,b);
}
set<pair<long,long> >M[1<<7];
vector<pair<long,long> >T[1<<7];
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)
		{
			int t=i&~x;
			for(int y=t;;y=y-1&t)
			{
				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;
		}
		T[i]=vector<pair<long,long> >(M[i].begin(),M[i].end());
	}
	for(int i=1;i+1<1<<N;i++)
	{
		int t=(1<<N)-1&~i;
		for(int j=t;;j=j-1&t)
		{
			int ii=0,jj=0;
			while(ii<T[i].size()&&jj<T[j].size())
			{
				if(T[i][ii]==T[j][jj])
				{
					cout<<"YES"<<endl;
					return 0;
				}
				else if(T[i][ii]<T[j][jj])ii++;
				else jj++;
			}
			if(j==0)break;
		}
	}
	cout<<"NO"<<endl;
}
0