結果
| 問題 | No.2392 二平方和 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-11-29 12:31:40 |
| 言語 | Haskell (9.14.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 2,000 ms |
| + 773µs | |
| コード長 | 2,073 bytes |
| 記録 | |
| コンパイル時間 | 9,427 ms |
| コンパイル使用メモリ | 197,760 KB |
| 実行使用メモリ | 8,364 KB |
| 最終ジャッジ日時 | 2026-11-29 12:31:53 |
| 合計ジャッジ時間 | 11,645 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
コンパイルメッセージ
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
ソースコード
{-# LANGUAGE BlockArguments #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
{-# OPTIONS_GHC -Wno-missing-signatures #-}
import Control.Monad
import Control.Monad.Reader
import Control.Monad.State.Strict
import Control.Applicative
import Data.Bool
import Data.Char
import Data.Function
import Data.List
import Data.Maybe
import Data.Ord
import Data.Ix (inRange)
import Data.List.Split
import Debug.Trace
import qualified Data.Char as C
-- import qualified Data.Set as Set
-- import qualified Data.Map.Strict as M
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
-- import Text.Printf
input = getLine :: IO String
ii = readLn :: IO Int
li = unfoldr (BS.readInt . BS.dropWhile C.isSpace) <$> BS.getLine
printYn b = putStrLn $ bool "No" "Yes" b
printList :: Show a => [a] -> IO ()
printList = putStrLn . unwords . map show
puts = putStrLn
divmod x y = (x `div` y, x `mod` y)
ceildiv a b = (a + b - 1) `div` b
len :: Foldable t => t a -> Int
len = length
rep = replicate
repM :: Applicative m => Int -> m a -> m [a]
repM = replicateM
repM_ :: Applicative m => Int -> m a -> m ()
repM_ = replicateM_
-- chunksOf
chunkBy = groupBy
fold :: Foldable t => (b -> a -> b) -> b -> t a -> b
fold = foldl'
pairwise :: [a] -> [(a, a)]
pairwise xs = zip xs (drop 1 xs)
windows :: Int -> [a] -> [[a]]
windows size xs
| length w < size = []
| otherwise = w : windows size (drop 1 xs)
where
w = take size xs
countIf f = length . filter f
minmax [] = error "minmax: empty list"
minmax (x:xs) = foldl' f (x, x) xs
where
f (mi, ma) y = (min mi y, max ma y)
takeEnd :: Int -> [a] -> [a]
takeEnd n = reverse . take n . reverse
class Indexable c where
at :: Int -> c a -> a
instance Indexable [] where
at i xs = xs !! i
instance Indexable V.Vector where
at i v = v V.! i
isqrt :: Int -> Int
isqrt = floor . sqrt . fromIntegral
main = do
p <- ii
let x = isqrt p
let f x = a + b == p
where
a = x*x
b = isqrt (p - a) ^ 2
let b = any f [1..x]
printYn b
norioc