結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー GOTKAKOGOTKAKO
提出日時 2023-12-02 14:47:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 725 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 203,444 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2023-12-02 14:47:39
合計ジャッジ時間 6,354 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
13,480 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>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int test; cin >> test;
    while(test--){
        long long M; cin >> M;
        long long power10 = 1;
        while(M%10 == 0) power10 *= 10,M /= 10;

        string s = "";
        for(int i=1; i<=9; i++){
            int d; cin >> d;
            while(d--) s += '0'+i;
        }

        bool ok = false;
        do{
            long long now = stoll(s);
            if(now%M == 0){
                ok = true;
                cout << now*power10 << endl;
                break;
            }
        }while(next_permutation(s.begin(),s.end()));
        
        if(!ok) cout << -1 << endl;
    }
}
0