結果

問題 No.1915 Addition
ユーザー TKG1TKG1
提出日時 2022-04-29 22:30:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-09-11 13:51:47
合計ジャッジ時間 2,889 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,040 KB
testcase_01 AC 77 ms
15,356 KB
testcase_02 AC 76 ms
15,088 KB
testcase_03 AC 81 ms
15,088 KB
testcase_04 AC 78 ms
15,224 KB
testcase_05 AC 77 ms
15,132 KB
testcase_06 AC 78 ms
15,152 KB
testcase_07 AC 76 ms
15,148 KB
testcase_08 AC 78 ms
15,312 KB
testcase_09 AC 78 ms
15,264 KB
testcase_10 AC 80 ms
15,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

t = gets.to_i
t.times do
  c = gets.to_i
  cs = c.to_s
  k = cs.size
  i = ('1' * k).to_i
  j = i

  while true
    if i.to_s.size > k
      k += 1
      i = ('1' * k).to_i
      j = i
    end
    x = 1
    x = i - c if i > c
    if (cs + x.to_s).to_i % (c + x) == 0
      puts x
      break
    end
    i += j
  end
end

0