結果
| 問題 | No.825 賢いお買い物 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-05-20 04:17:01 | 
| 言語 | Nim (2.2.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,072 bytes | 
| コンパイル時間 | 2,238 ms | 
| コンパイル使用メモリ | 60,988 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-02 01:35:30 | 
| 合計ジャッジ時間 | 3,217 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
import sequtils
template times*(n:int,body) = (for _ in 0..<n: body)
template `max=`*(x,y) = x = max(x,y)
template `min=`*(x,y) = x = min(x,y)
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" ,discardable.}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': return
    result = 10 * result + k.ord - '0'.ord
proc solve(a,b,c:int):int =
  # A 10B -> A+B=C
  # 15 + 15*10
  for x in 1..a+b*10:
    for ia in 0..a:
      for ib in 0..b:
        # x円のものを ia+ib*10円で払う
        let g = ia + ib*10 - x
        if g < 0 : continue
        let res = (a-ia) + (b-ib) + (g mod 10) + (g div 10)
        if res != c : continue
        return x
  return -1
# const ABC = (
#   proc():seq[seq[seq[int]]] =
#     result = newSeqWith(21,newSeqWith(21,newSeqWith(101,0)))
#     for a in 0..20:
#       for b in 0..20:
#         for c in 0..100:
#           result[a][b][c] = solve(a,b,c)
#   )()
let a = scan()
let b = scan()
let c = scan()
let ans = solve(a,b,c)
if ans == -1 : echo "Impossible"
else: echo ans
            
            
            
        