結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー YukiYuki
提出日時 2023-12-07 19:06:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 171,120 KB
実行使用メモリ 10,004 KB
最終ジャッジ日時 2023-12-07 19:06:53
合計ジャッジ時間 6,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (int)s; i < (int)(n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int T;
  cin >> T;
  rep(_, T) {
    int M;
    cin >> M;
    vector<int> d(9);
    rep(i, 9) cin >> d[i];

    vector<int> arr;
    rep(i, 9) {
      rep(j, d[i]) {
        arr.push_back(i + 1);
      }
    }
    do {
      int num = 0;
      rep(i, arr.size()) {
        num *= 10;
        num += arr[i];
      }
      if (num % M == 0) {
        cout << num << endl;
        break;
      }

    } while (next_permutation(arr.begin(), arr.end()));
  }
}
0