結果

問題 No.2562 数字探しゲーム(緑以下コンver.)
ユーザー chaemonchaemon
提出日時 2023-12-02 14:57:45
言語 Nim
(2.0.2)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 15,090 bytes
コンパイル時間 4,044 ms
コンパイル使用メモリ 94,464 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-19 21:28:59
合計ジャッジ時間 4,907 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import macros
macro Please(x): untyped = nnkStmtList.newTree()

Please use Nim-ACL
Please use Nim-ACL
Please use Nim-ACL


static:
  when not defined SecondCompile:
    # md5sum: 6f8db07592f759514dc56820d97e4a09  atcoder.tar.xz

    template getFileName():string = instantiationInfo().filename
    let fn = getFileName()
    block:
      let (output, ex) = gorgeEx("if [ -e ./atcoder ]; then exit 1; else exit 0; fi")
      # doAssert ex == 0, "atcoder directory already exisits"
    discard staticExec("echo \"/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4O//J31dADCdCIqmAHyeLmzPetXzWpgQcDgKgJF+nO8CaeoEXtPPCtnQW1u46k+GAyq6XR9EAgzfWv0tTcnMCd0J2TGdLyQZ3a2wYdlm0WLbBYbmWZS8XjzCeWVRr55u0BcDE0pMm5iLrYBYhbJEumxmO+/KvMmMIopS8WlhR+pYVHuqASWzK872Pz8jnDhcE+4IIFZ4sjwQYMhVeZgtctIlXk9EY8/EF3M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51dqyyxcvGS5yrG/kiz9DngNLeBUTEYaCFH28f6uZow3WSSLb/sItlxFMqJiSNGoKS8ohefx3N+8G3yKe3alS+MMlFCwX5qIJlMJkBuMObR/aYcWMi8VcWU40bcDu4IcAgtV9+m6n3PfWElnjrGMzCii9OStd7WgK/QZzQXKyR7DFV2hAA6V6haYnw2fii7XDiH4XIwVyxweflpnTwpozfv+9hgD58nRHOwmqxRY+IcYi9pWGG0MklxlK52yeR8eFZj5F1rdsdRGxxQHXRcjjQphH38RTTgwJ8PWR6gC3WXmMqAyOZ7WLGgpQ3L2e7UNK4ZtZm1sQJwAAAAAAEcPfngrsUrYAAGZT4DgAwCWaQlMscRn+wIAAAAABFla\" | base64 -d > atcoder.tar.xz && tar -Jxvf atcoder.tar.xz")
    let (output, ex) = gorgeEx("nim cpp -d:release -d:SecondCompile -d:danger --path:./ --opt:speed --multimethods:on --warning[SmallLshouldNotBeUsed]:off --checks:off -o:a.out " & fn)
    discard staticExec("rm -rf ./atcoder");doAssert ex == 0, output;quit(0)


when defined SecondCompile:
  const DO_CHECK = false;const DEBUG = false
else:
  const DO_CHECK = true;const DEBUG = true
const
  USE_DEFAULT_TABLE = true
  DO_TEST = false

# see https://github.com/zer0-star/Nim-ACL/tree/master/src/atcoder/extra/header/chaemon_header.nim
include atcoder/extra/header/chaemon_header


proc solve() =
  let T = nextInt()
  for _ in T:
    let M = nextInt()
    var d = Seq[9: nextInt()]
    var X = 0
    for i in 9:
      for _ in d[i]:
        X *= 10
        X += i + 1
    X *= 10^9
    let r = X mod M
    if X == 0:
      X = M
    elif r > 0:
      X += M - r
    doAssert X mod M == 0
    doAssert X in 1 .. 10^18
    echo X
  discard

solve()

0