CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:funkar
Submission time:2017-10-09 23:16:38 +0300
Language:Haskell
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#3ACCEPTED63
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.06 s2details
#3ACCEPTED0.07 s3details

Compiler report

input/code.hs:22:1: Warning:
    Top-level binding with no type signature: main :: IO ()

Code

import Data.List

findLog :: Int -> Int
valueOf :: Int -> Int
champ :: Int -> Char
csum :: [Int]
c :: [Int]

c = [9*n*10^(n-1) | n <- [1..17]]
csum = [1 + (sum $ take n c) | n <- [1..17]]
findLog x = maybe 0 id $ findIndex (>=x+1) csum
valueOf x
  | x <= 10 = x
  | x == 11 = 10
  | otherwise = ((x-csum !! (b-1)) `div` (b+1)) + 10^b
  where b = findLog x
champ x
  | x <= 10 = show(x) !! 0
  | otherwise = show(valueOf x) !! ((x - csum !! (b-1)) `mod` (b+1))
  where b = findLog x

main = do
  _ <- getLine
  z <- getContents
  let zs = [read x | x <- (lines z)]
  mapM_ putStrLn [champ x : "" | x <- zs]

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