結果

問題 No.420 mod2漸化式
ユーザー alpha_virginis
提出日時 2016-09-09 23:07:01
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,001 bytes
コンパイル時間 3,413 ms
コンパイル使用メモリ 181,540 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2024-12-24 11:13:36
合計ジャッジ時間 4,464 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
プレゼンテーションモードにする

{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as C
import Data.Char
import Text.Printf
nCr :: Integer -> Integer -> Integer
nCr n r = foldl (*) 1 [n-r+1..n] `div` foldl (*) 1 [1..r]
solve :: Int -> (Integer, Integer)
solve n
| n < 32 = (x, y)
| otherwise = (0, 0)
where n' = fromIntegral n
x = nCr 31 n'
y = (2 ^ (31 :: Integer) - 1) * x * n' `div` 31
main :: IO ()
main = do
ss <- C.getLine
let (x, ss2) = nextInt ss
let (a, b) = solve x
printf "%d %d\n" a b
nextInt :: C.ByteString -> (Int, C.ByteString)
nextInt ss
| isDigit x || x == '-' = nextInt2 0 ss
| otherwise = nextInt $ C.tail ss
where x = C.head ss
nextInt2 :: Int -> C.ByteString -> (Int, C.ByteString)
nextInt2 n ss
| C.null ss = (n, ss)
| y == '-' = (-z,zs)
| isDigit y = nextInt2 (n * 10 + (digitToInt y)) ys
| otherwise = (n, ys)
where y = C.head ss
ys = C.tail ss
(z,zs) = nextInt2 0 ys
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0