結果

問題 No.2455 Numbers Dictionary
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-09-01 22:32:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 2,013 ms
コンパイル使用メモリ 199,136 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-01 22:32:43
合計ジャッジ時間 4,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 37 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 42 ms
4,380 KB
testcase_11 AC 43 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 42 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 44 ms
4,376 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
	string s;
	string t;
	cin >> s >> t;
	ll ans = 0;
	int n = s.size(), nk = t.size();
	ll val[20];
	for (int i = 0; i < n - 1; i ++) {
		val[i] = stoll(s.substr(i + 1, n - i - 1));
	}
	val[n - 1] = 0;
	ll tm[20];
	tm[0] = 1;
	for (int i = 1; i < 18; i ++) {
		tm[i] = tm[i - 1] * 10;
	}
	for (int pkj = 0; pkj < nk; pkj ++) {
		// ll sm = 0;
		int i = (pkj == 0);
		for (; i < t[pkj] - '0'; i ++) {
			ll nm = 0;
			for (int x = 0; x < n - pkj; x ++) {
				if (i == s[pkj] - '0' && x == n - pkj - 1) {
					nm += val[pkj];
				} else if (i > s[pkj] - '0') {
                    break;
                } else {
					nm += tm[x];
				}
			}
			ans += nm;
		}
        ans ++;
	}
	cout << ans << endl;
}
int main () {
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
}
0