結果

問題 No.528 10^9と10^9+7と回文
ユーザー letrangerjpletrangerjp
提出日時 2017-06-09 23:21:00
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 320 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 21,272 KB
最終ジャッジ日時 2023-10-24 01:58:52
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
16,080 KB
testcase_01 AC 79 ms
16,140 KB
testcase_02 AC 78 ms
16,140 KB
testcase_03 AC 78 ms
16,140 KB
testcase_04 AC 83 ms
16,140 KB
testcase_05 AC 79 ms
16,140 KB
testcase_06 AC 84 ms
16,344 KB
testcase_07 AC 83 ms
16,344 KB
testcase_08 AC 83 ms
16,344 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
cnt1 = cnt2 = 0
MOD1 = 10**9
MOD2 = MOD1 + 7

digits = Math.log10(N+1).ceil
digits.times.each{|d|
  v = 10 ** (d / 2) * 9
  cnt1 = (cnt1 + v) % MOD1
  cnt2 = (cnt2 + v) % MOD2
}

M = 10 ** digits
# p [M, N, cnt1]
M.downto(N+1){|i|
  next if i.to_s != i.to_s.reverse
  cnt1 -= 1
  cnt2 -= 1
}
p cnt1
p cnt2
0