結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー GOTKAKOGOTKAKO
提出日時 2023-12-02 14:47:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 725 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 203,020 KB
実行使用メモリ 16,836 KB
最終ジャッジ日時 2024-11-19 21:28:30
合計ジャッジ時間 22,273 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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