結果
| 問題 | No.825 賢いお買い物 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-12-30 17:49:03 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 432 bytes | 
| コンパイル時間 | 142 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 12,288 KB | 
| 最終ジャッジ日時 | 2024-11-09 00:48:49 | 
| 合計ジャッジ時間 | 2,932 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 WA * 1 | 
コンパイルメッセージ
Syntax OK
ソースコード
def f()
  a,b,c = gets.split.map(&:to_i)
  if c > a + b
    return "Impossible"
  end
  s = 10**10
  for i in 0..a do
    for j in 0..b do
      if i + j == 0
        next
      end
      t = i + j * 10
      for k in 1..t do
        r = t - k
        an, bn = a - i + r % 10, b - j + r / 10
        if an + bn == c
          s = [s, t-r].min
        end 
      end
    end
  end
  return s < 10**10 ? s : "Impossible"
end
puts f()
            
            
            
        