結果

問題 No.491 10^9+1と回文
コンテスト
ユーザー tottoripaper
提出日時 2017-03-11 21:23:12
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 399 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,732 ms
コンパイル使用メモリ 197,760 KB
実行使用メモリ 17,152 KB
最終ジャッジ日時 2026-04-17 08:58:52
合計ジャッジ時間 8,534 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 103
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

palindrome :: Int -> [Int]
palindrome d = map (foldr (\x acc -> x + acc * 10) 0) $ palindrome' d 1
  where
    palindrome' 1 i = [ [x] | x <- [i..9] ]
    palindrome' 2 i = [ [x, x] | x <- [i..9] ]
    palindrome' d i = [ x : (l ++ [x]) | x <- [i..9], l <- palindrome' (d-2) 0 ]

pa = concat (map palindrome [1..9])

main = do
  n <- readLn
  print $ length $ filter (\m -> m * (10 ^ 9 + 1) <= n) pa
0