結果

問題 No.316 もっと刺激的なFizzBuzzをください
コンテスト
ユーザー ducktail
提出日時 2018-05-06 22:09:19
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 988µs
コード長 385 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,863 ms
コンパイル使用メモリ 197,376 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-07-31 14:21:39
合計ジャッジ時間 3,525 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

import Control.Applicative ((<$>), (<*>))

main :: IO ()
main = solve <$> readLn <*> (map read <$> words <$> getLine) >>= print

solve :: Int -> [Int] -> Int
solve n [a, b, c] = (n `div` a) + (n `div` b) + (n `div` c)
                    - (n `div` ab) - (n `div` bc) - (n `div` ca) + (n `div` abc)
  where ab = lcm a b
        bc = lcm b c
        ca = lcm c a
        abc = lcm ab c
0