結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー SotaSota
提出日時 2024-02-15 12:38:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,202 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 104,672 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2024-02-15 12:38:49
合計ジャッジ時間 5,716 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>		//cin, cout
#include <vector>		//vector
#include <algorithm>	//sort,min,max,count
#include <string>		//string,getline, to_string
#include <cstdlib>		//abs(int)
#include <utility>		//swap, pair
#include <tuple>        //tuple
#include <deque>		//deque
#include <climits>		//INT_MAX
#include <bitset>		//bitset
#include <cmath>		//sqrt, ceil. M_PI, pow, sin
#include <ios>			//fixed
#include <iomanip>		//setprecision
#include <sstream>		//stringstream
#include <numeric>		//gcd, assumlate
#include <random>		//randam_device
#include <limits>		//numeric_limits

using namespace std;
constexpr long long int D_MOD = 1000000007;

int main() {

	int T;
	cin >> T;

	int64_t M, X;
	int d;
	string S, A, B;

	for (int i = 0; i < T; i++) {
		cin >> M;
		X = M;
		S.clear();

		for (int j = 1; j <= 9; j++) {
			cin >> d;
			if (d != 0) {
				for (int k = 0; k < d; k++) {
					S.push_back(j + '0');
				}
			}
		}
		if (M == 1) {
			cout << S << endl;
			continue;
		}

		B = S;
		sort(B.begin(), B.end());

		while (1) {
			A = to_string(X);
			sort(A.begin(), A.end());

			if (A == B) {
				cout << X << endl;
				break;
			}

			X += M;
		}
	}

	return 0;

}
0