結果

問題 No.683 Two Operations No.3
ユーザー ducktailducktail
提出日時 2018-05-11 23:11:52
言語 Haskell
(9.8.2)
結果
MLE  
実行時間 -
コード長 527 bytes
コンパイル時間 12,524 ms
コンパイル使用メモリ 166,572 KB
実行使用メモリ 698,212 KB
最終ジャッジ日時 2023-09-10 17:48:56
合計ジャッジ時間 18,175 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,136 KB
testcase_01 AC 2 ms
7,008 KB
testcase_02 AC 2 ms
7,012 KB
testcase_03 AC 2 ms
7,040 KB
testcase_04 MLE -
testcase_05 AC 5 ms
8,956 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>))

main :: IO ()
main = solve <$> map read <$> words <$> getLine >>= putStrLn

solve :: [Int] -> String
solve [a, b] = case [(a, b)] >>= dfs of
                [] -> "No"
                _ -> "Yes"

dfs :: (Int, Int) -> [(Int, Int)]
dfs (x, y) | x == 0 && y == 0 = [(0, 0)]
           | odd x && odd y = []
           | odd x && even y = [(x-1, y `div` 2)] >>= dfs 
           | even x && odd y = [(x `div` 2, y-1)] >>= dfs
           | otherwise = [(x-1, y `div` 2), (x `div` 2, y-1)] >>= dfs
0