結果

問題 No.3024 等式
ユーザー ei1333333ei1333333
提出日時 2017-08-16 01:27:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 164,904 KB
実行使用メモリ 203,292 KB
最終ジャッジ日時 2024-04-21 12:40:11
合計ジャッジ時間 10,200 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 165 ms
15,488 KB
testcase_16 AC 146 ms
12,544 KB
testcase_17 AC 148 ms
13,952 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

int main()
{
  set< double > dp[1 << 7];
  int N, A[7];

  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];

  for(int i = 0; i < N; i++) {
    dp[1 << i].emplace(A[i]);
  }
  for(int i = 0; i < (1 << N); i++) {
    for(int j = 0; j < (1 << N); j++) {
      if(i & j) continue;
      for(auto &k : dp[i]) {
        for(auto &l : dp[j]) {
          dp[i | j].emplace(j + k);
          dp[i | j].emplace(j - k);
          dp[i | j].emplace(j * k);
          if(k != 0.0) dp[i | j].emplace(j / k);
        }
      }
    }
  }

  for(int i = 0; i < (1 << N); i++) {
    for(int j = 0; j < (1 << N); j++) {
      if(i & j) continue;
      for(auto &k : dp[i]) {
        if(dp[j].count(k)) {
          cout << "YES" << endl;
          return (0);
        }
      }
    }
  }
  cout << "NO" << endl;
}
0