結果

問題 No.719 Coprime
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-12-10 19:53:06
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 161,984 KB
実行使用メモリ 8,536 KB
最終ジャッジ日時 2023-10-14 22:16:32
合計ジャッジ時間 3,444 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,504 KB
testcase_01 AC 3 ms
7,364 KB
testcase_02 AC 3 ms
7,400 KB
testcase_03 AC 3 ms
7,300 KB
testcase_04 AC 3 ms
7,312 KB
testcase_05 AC 3 ms
7,408 KB
testcase_06 AC 2 ms
7,316 KB
testcase_07 AC 3 ms
7,368 KB
testcase_08 AC 3 ms
7,396 KB
testcase_09 AC 3 ms
7,448 KB
testcase_10 AC 3 ms
7,392 KB
testcase_11 AC 3 ms
7,360 KB
testcase_12 AC 2 ms
7,376 KB
testcase_13 AC 2 ms
7,456 KB
testcase_14 AC 3 ms
7,432 KB
testcase_15 AC 2 ms
7,380 KB
testcase_16 AC 3 ms
7,440 KB
testcase_17 AC 3 ms
7,436 KB
testcase_18 AC 2 ms
7,372 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
7,444 KB
testcase_26 AC 3 ms
7,396 KB
testcase_27 AC 3 ms
7,392 KB
testcase_28 AC 2 ms
7,376 KB
testcase_29 AC 2 ms
7,388 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 qualified Data.Map as Map
import Data.List

f::Int->Int->[Int]
f 1 _=[]
f 2 _=[2]
f 3 _=[3]
f n d
   |n `mod` d==0=d:f (n `div` d) d
   |otherwise=f n (d+1)

h::[Int]->Map.Map Int Int ->[Int]->Int
h [] _ ds=sum (nub ds)
h (x:xs) ms ds
     |(Map.member x ms)==True=let Just y=Map.lookup x ms
                              in h xs ms (y:ds)
     |otherwise=h xs ms ds

f2::Int->[Int]->Map.Map Int Int->Map.Map Int Int
f2 _ [] ms=ms
f2 n (x:xs) ms=let ms2=Map.insert x n ms
               in f2 n xs ms2

g::Int->Int->Map.Map Int Int->Int
g n m ms
   |n>m=sum (nub (Map.elems ms))
g n m ms=let xs=f n 2
             t=h xs ms [0]
             ms2=f2 n xs ms
         in if t>n then g (n+1) m ms 
                   else g (n+1) m ms2

main = do
       e<-getLine
       let n=read e::Int
       print $ g 2 n (Map.fromList [(0::Int,0::Int)])
0