結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 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
ソースコード
LANGUAGEimportqualifiedData.ByteString.CharasCimportData.CharimportText.PrintfnCr::Integer->Integer->IntegernCr n r = foldl (*) 1 [n-r+1..n] `div` foldl (*) 1 [1..r]solve::Int->IntegerIntegersolve n| n < 32 = (x, y)| otherwise = (0, 0)where n' = fromIntegral nx = nCr 31 n'y = (2 ^ (31 :: Integer) - 1) * x * n' `div` 31main::IO()main = doss <- C.getLinelet (x, ss2) = nextInt sslet (a, b) = solve xprintf "%d %d\n" a bnextInt::CByteString->IntCByteStringnextInt ss| isDigit x || x == '-' = nextInt2 0 ss| otherwise = nextInt $ C.tail sswhere x = C.head ssnextInt2::Int->CByteString->IntCByteStringnextInt2 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 ssys = C.tail ss(z,zs) = nextInt2 0 ys