結果

問題 No.528 10^9と10^9+7と回文
ユーザー letrangerjpletrangerjp
提出日時 2017-06-09 23:18:58
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 301 bytes
コンパイル時間 1,060 ms
コンパイル使用メモリ 11,836 KB
実行使用メモリ 16,312 KB
最終ジャッジ日時 2023-10-24 01:53:13
合計ジャッジ時間 5,159 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 83 ms
16,108 KB
testcase_02 AC 84 ms
16,108 KB
testcase_03 AC 84 ms
16,108 KB
testcase_04 AC 84 ms
16,108 KB
testcase_05 AC 85 ms
16,108 KB
testcase_06 AC 90 ms
16,312 KB
testcase_07 AC 89 ms
16,312 KB
testcase_08 AC 90 ms
16,312 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).ceil
digits.times.each{|d|
  v = 10 ** (d / 2) * 9
  cnt1 = (cnt1 + v) % MOD1
  cnt2 = (cnt2 + v) % MOD2
}

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