結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー norikamenorikame
提出日時 2023-12-03 18:49:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 924 bytes
コンパイル時間 4,305 ms
コンパイル使用メモリ 263,716 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-03 18:49:49
合計ジャッジ時間 5,696 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int t0;
	cin >> t0;
	rep(i0, t0) {
		int m;
		cin >> m;
		vector<int> d(10);
		rep3(i, 1, 10) cin >> d[i];
		if (accumulate(all(d), 0) == 0) {
			cout << m << endl;
			continue;
		}
		string s;
		rep3(i, 1, 10) s += string(d[i], '0'+i);
		int ten = 0, tar = 1;
		ll x = 0;
		while (1) {
			int mval = (m - stoll(s+string(ten,'0')) % m) % m;
			if (mval < tar) {
				x = stoll(s+string(ten,'0')) + mval;
				break;
			}
			++ten;
			tar *= 10;
		}
		cout << x << endl;
	}
	return 0;
}
0