結果
| 問題 | No.3150 count X which satisfies with equlation | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-05-20 22:02:07 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 2,949 bytes | 
| コンパイル時間 | 10,256 ms | 
| コンパイル使用メモリ | 205,548 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-06-20 03:00:26 | 
| 合計ジャッジ時間 | 9,451 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 42 | 
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
Main.hs:32:30: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but defined in GHC.Internal.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
   |
32 |     x' = if nx then '0' else head xs
   |                              ^^^^
Main.hs:33:30: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but defined in GHC.Internal.List):
    "This is a partial function, it throws an error on empty lists. Use pattern matching, 'Data.List.uncons' or 'Data.Maybe.listToMaybe' instead. Consider refactoring to use "Data.List.NonEmpty"."
   |
33 |     y' = if ny then '0' else head ys
   |                              ^^^^
Main.hs:34:29: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.Internal.List):
    "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"."
   |
34 |     tx = if nx then [] else tail xs
   |                             ^^^^
Main.hs:35:29: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.Internal.List):
    "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"."
   |
35 |     ty = if ny then [] else tail ys
   |                             ^^^^
Main.hs:98:14: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, but d
            
            ソースコード
{-# OPTIONS_GHC -Wno-unused-imports -Wno-unused-top-binds #-}
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Control.Monad.ST             
import Data.Ix
import Data.Array (Array)
import Data.Array.IArray
import Data.Array.IO             
import Data.Array.MArray          
import Data.Array.ST                
import Data.Array.Unboxed (UArray)
import Data.Char
import Data.List as L
import Data.Foldable
import Data.Function
import Control.Exception
import Data.Array.Base (STUArray(STUArray), UArray (UArray))
import Data.Array.IO.Internals (IOUArray(IOUArray))
import Data.Ord
import GHC.Float
toBinary = toXnary 2
myZip xs ys m
  | nx && ny = m 
  | otherwise = myZip tx ty (z' : m)
  where
    nx = null xs
    ny = null ys
    z' = (x', y')
    x' = if nx then '0' else head xs
    y' = if ny then '0' else head ys
    tx = if nx then [] else tail xs
    ty = if ny then [] else tail ys
f :: (Char, Char) -> Int
f ('1', '1') = 2
f ('0', '0') = 1
f ('1', '0') = 0
f ('0', '1') = 1
main :: IO ()
main = do
  [a, b] <- getIntList
  let 
    a' = reverse $ toBinary a
    b' = reverse $ toBinary b
    zs = myZip a' b' []
    ans = product $ map f zs
  print ans
--library--------------
modulus :: Int
modulus = 10 ^ 9 + 7
addMod, subMod, mulMod :: Int -> Int -> Int
addMod x y = (x + y) `mod` modulus
subMod x y = (x - y) `mod` modulus
mulMod x y = (x * y) `mod` modulus
tuplify2 :: [b] -> (b, b)
tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt
readIntTuple :: BS.ByteString -> (Int, Int)
readIntTuple = tuplify2 . map readInt . BS.words
readIntList :: BS.ByteString -> [Int]
readIntList = map readInt . BS.words
getInt :: IO Int
getInt = readInt <$> BS.getLine
getIntList :: IO [Int]
getIntList = readIntList <$> BS.getLine
getIntListX :: IO [Int]
getIntListX = readIntList <$> BS.getContents
getIntNList :: Integral a => a -> IO [[Int]]
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix :: IO [[Int]]
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple :: IO (Int, Int)
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples :: Integral a => a -> IO [(Int, Int)]
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples :: IO [(Int, Int)]
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents
getIntMatArr :: Int -> Int -> IO (UArray (Int, Int) Int)
getIntMatArr h w = listArray ((1, 1), (h, w)) . concat <$> getIntNList h
yn :: Bool -> IO ()
yn bl = putStrLn $ if bl then "Yes" else "No"
putInts :: [Int] -> IO ()
putInts x = putStrLn $ unwords $ map show x
nubOrd :: Eq a => Ord a => [a] -> [a]
nubOrd = map head.group.sort
toXnary :: (Show a, Integral a) => a -> a -> String 
toXnary x n = concatMap show $ reverse $ help x n
  where
    help x n
      | n == 0 = []
      | otherwise = mod n x : help x (div n x)
            
            
            
        