結果
| 問題 |
No.8024 等式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-09 08:12:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,512 bytes |
| コンパイル時間 | 1,193 ms |
| コンパイル使用メモリ | 83,104 KB |
| 実行使用メモリ | 438,956 KB |
| 最終ジャッジ日時 | 2024-11-07 20:47:19 |
| 合計ジャッジ時間 | 19,689 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 3 -- * 2 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main()
| ^~~~
ソースコード
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
vector<pair<long,long> >M[1<<7];
int N;
long A[7];
main()
{
cin>>N;
for(int i=0;i<N;i++)
{
cin>>A[i];
M[1<<i].push_back(make_pair(A[i],1));
}
for(int i=1;i+1<1<<N;i++)
{
if(__builtin_popcount(i)>1)
{
for(int x=i;;x=x-1&i)
{
int y=i&~x;
for(const pair<long,long>&X:M[x])
{
for(const pair<long,long>&Y:M[y])
{
M[i].push_back(make_pair(X.first*Y.second+Y.first*X.second,X.second*Y.second));
M[i].push_back(make_pair(X.first*Y.second-Y.first*X.second,X.second*Y.second));
M[i].push_back(make_pair(-X.first*Y.second+Y.first*X.second,X.second*Y.second));
M[i].push_back(make_pair(X.first*Y.first,X.second*Y.second));
M[i].push_back(make_pair(X.first*Y.second,X.second*Y.first));
M[i].push_back(make_pair(Y.first*X.second,Y.second*X.first));
}
}
if(x==0)break;
}
}
for(pair<long,long>&p:M[i])
{
long g=gcd(p.first,p.second);
p.first/=g;
p.second/=g;
}
sort(M[i].begin(),M[i].end());
M[i].erase(unique(M[i].begin(),M[i].end()),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<M[i].size()&&jj<M[j].size())
{
if(M[i][ii]==M[j][jj])
{
cout<<"YES"<<endl;
return 0;
}
else if(M[i][ii]<M[j][jj])ii++;
else jj++;
}
if(j==0)break;
}
}
cout<<"NO"<<endl;
}