結果

問題 No.1737 One to N
ユーザー sanao10000sanao10000
提出日時 2021-11-12 23:14:30
言語 Haskell
(9.8.2)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 3,292 bytes
コンパイル時間 17,130 ms
コンパイル使用メモリ 228,892 KB
実行使用メモリ 7,280 KB
最終ジャッジ日時 2023-08-17 03:47:52
合計ジャッジ時間 18,066 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,240 KB
testcase_01 AC 3 ms
7,208 KB
testcase_02 AC 3 ms
7,248 KB
testcase_03 AC 2 ms
7,164 KB
testcase_04 AC 2 ms
7,172 KB
testcase_05 AC 3 ms
7,156 KB
testcase_06 AC 4 ms
7,120 KB
testcase_07 AC 6 ms
7,092 KB
testcase_08 AC 3 ms
7,176 KB
testcase_09 AC 3 ms
7,128 KB
testcase_10 AC 3 ms
7,184 KB
testcase_11 AC 3 ms
7,160 KB
testcase_12 AC 2 ms
7,184 KB
testcase_13 AC 3 ms
7,276 KB
testcase_14 AC 3 ms
7,172 KB
testcase_15 AC 3 ms
7,168 KB
testcase_16 AC 2 ms
7,184 KB
testcase_17 AC 3 ms
7,088 KB
testcase_18 AC 3 ms
7,156 KB
testcase_19 AC 3 ms
7,272 KB
testcase_20 AC 2 ms
7,188 KB
testcase_21 AC 2 ms
7,156 KB
testcase_22 AC 2 ms
7,252 KB
testcase_23 AC 2 ms
7,156 KB
testcase_24 AC 2 ms
7,084 KB
testcase_25 AC 3 ms
7,280 KB
testcase_26 AC 3 ms
7,088 KB
testcase_27 AC 3 ms
7,084 KB
testcase_28 AC 3 ms
7,196 KB
testcase_29 AC 3 ms
7,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts    #-}
{-# LANGUAGE FlexibleInstances   #-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Applicative
import Control.Monad.State
import qualified Numeric                       as Nu
import qualified Control.Monad                 as CM
import qualified Data.List                     as L
import qualified Control.Monad.ST              as ST
import qualified Data.ByteString.Char8         as BS
import qualified Data.Array                    as A
import qualified Data.Array.IO                 as AI
import qualified Data.Char                     as Ch
import qualified Data.Text                     as T
import qualified Data.IORef                    as IO
import qualified Data.Text.IO                  as T
import qualified Data.Array.ST                 as AST
import qualified Data.ByteString.Builder       as BB
import qualified Data.Set                      as Set
import qualified Data.Map.Strict               as Map
import qualified Data.Sequence                 as Seq
import qualified Data.Maybe                    as May
import Data.Graph

import Prelude hiding (print)


main = do
    n <- cin @Int
    print$sum$solve n


solve :: Int -> [Int]
solve n =
    let f n = if n == 1
              then []
              else
                let d = L.head $ L.filter (\x -> n `mod` x == 0) [2..n]
                in d : f (n `div` d)
                in f n

type Moji= BS.ByteString



buildUndirected :: [(Int,Int)] -> [(Int,Int)]
buildUndirected x= Set.toList$Set.fromList $ concatMap (\ (a, b) -> [(a, b), (b, a)]) x



print :: Show a => a -> IO ()
print x=BS.putStrLn $ BS.pack $ show x

class Sanao a where
  sanao :: Moji -> a
  {-# MINIMAL sanao #-}

instance Sanao Moji  where
  sanao= id

instance Sanao Int where
    sanao x= case BS.readInt x of
                Nothing -> error "ここはInt"
                Just (a,_) -> a

instance Sanao Double where
    sanao x= case BS.readInt x of
                Nothing -> error "ここはDouble"
                Just (a,_) -> realToFrac a

instance Sanao [Moji] where
    sanao=BS.words

instance (Sanao a)=>Sanao [a] where
    sanao= map sanao.BS.words

instance Sanao(Int,Int) where
    sanao= (\[a, b]->(a, b)) . map sanao . BS.words

instance Sanao(Int, Int, Int) where
    sanao= (\[a, b, c]->(a, b, c)) . map sanao . BS.words

instance Sanao(Int, Int, Int, Int) where
    sanao= (\[a, b, c, d]->(a, b, c, d)) . map sanao . BS.words

instance Sanao(Double,Double) where
    sanao= (\[a, b]->(a, b)) . map sanao . BS.words

instance Sanao(Double,Double, Double) where
    sanao= (\[a, b, c]->(a, b, c)) . map sanao . BS.words

instance Sanao(Double,Double, Double, Double) where
    sanao= (\[a, b, c, d]->(a, b, c, d)) . map sanao . BS.words

instance Sanao(Moji,Int) where
    sanao= (\[a, b]->(a,sanao b)) . BS.words

instance Sanao(Moji,Int, Int) where
    sanao= (\[a, b, c]->(a,sanao b, sanao c)) . BS.words

instance Sanao(Int,Moji) where
    sanao= (\[a, b]->(sanao a,b)) . BS.words

instance Sanao(Moji,Double) where
    sanao= (\[a, b]->(a,sanao b)) . BS.words

cin::Sanao a=>IO a
cin=sanao<$>BS.getLine

instance Sanao(Double,Moji) where
    sanao= (\[a, b]->(sanao a,b)) . BS.words

0