結果
問題 |
No.2562 数字探しゲーム(緑以下コンver.)
|
ユーザー |
![]() |
提出日時 | 2024-11-28 23:56:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 2,592 ms |
コンパイル使用メモリ | 248,728 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-28 23:56:37 |
合計ジャッジ時間 | 3,519 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; int main() { int t; cin >> t; while (t--) { lint m; cin >> m; vector<lint> d(10); for (int i = 1; i <= 9; i++) { cin >> d[i]; } if (accumulate(d.begin(), d.end(), 0LL) == 0LL) { cout << m << endl; continue; } lint ans = 0; lint ten = 1; for (lint i = 1; i <= 9; i++) { while (d[i]--) { ans += ten * i; ten *= 10LL; } } lint digit = to_string(m - 1).size(); ans *= powl(10LL, digit); lint r = ans % m; if (r > 0) { ans += m - r; } cout << ans << endl; } }