Task: | Kyselyt |
Sender: | FSMnArmosta |
Submission time: | 2017-10-02 12:07:50 +0300 |
Language: | Haskell |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 25 |
#3 | ACCEPTED | 63 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1 | details |
#2 | ACCEPTED | 0.05 s | 2 | details |
#3 | ACCEPTED | 0.04 s | 3 | details |
Compiler report
input/code.hs:2:1: Warning: The import of `Data.List' is redundant except perhaps to import instances from `Data.List' To import instances alone, use: import Data.List() input/code.hs:7:1: Warning: Top-level binding with no type signature: toActualInt :: forall t t1. Maybe (t, t1) -> t input/code.hs:7:1: Warning: Pattern match(es) are non-exhaustive In an equation for `toActualInt': Patterns not matched: Nothing input/code.hs:7:23: Warning: Defined but not used: `b' input/code.hs:13:1: Warning: Top-level binding with no type signature: numbersBefore :: Int -> (Int, Int) input/code.hs:14:1: Warning: Top-level binding with no type signature: numberAt :: Int -> [Char]
Code
import Control.Monad import Data.List import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as C8 toActualInt (Just (a, b)) = a numberLengthSum :: Int -> Int -> Int -> (Int, Int) numberLengthSum soFar powerOfTen maximumIndex = if tentative > maximumIndex then (soFar, powerOfTen) else numberLengthSum tentative (powerOfTen + 1) maximumIndex where tentative = soFar + (10^powerOfTen-10^(powerOfTen-1))*powerOfTen numbersBefore a = numberLengthSum 1 1 a numberAt a = [(show integerAt)!!((a-charactersBefore) `rem` powerOfTen)] where (charactersBefore, powerOfTen) = numbersBefore a integerAt = 10^(powerOfTen-1) + ((a - charactersBefore) `div` powerOfTen) main :: IO () main = do num <- getLine inputs <- replicateM (read num) B.getLine let queries = map (toActualInt . C8.readInt) inputs putStrLn (unlines (map (numberAt) (queries)))
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
1000 582 214 723 273 ... |
correct output |
---|
0 1 7 7 6 ... |
user output |
---|
0 1 7 7 6 ... Truncated |
Test 2
Group: 2
Verdict: ACCEPTED
input |
---|
1000 615664 916441 627600 279508 ... |
correct output |
---|
1 2 3 2 2 ... |
user output |
---|
1 2 3 2 2 ... Truncated |
Test 3
Group: 3
Verdict: ACCEPTED
input |
---|
1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
correct output |
---|
7 2 2 0 9 ... |
user output |
---|
7 2 2 0 9 ... Truncated |