CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:funkar
Submission time:2017-10-09 22:39:53 +0300
Language:Haskell
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.04 s1details
#20.05 s2details
#30.06 s3details

Compiler report

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

input/code.hs:26:1: Warning:
    Top-level binding with no type signature: loop :: 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
  loop

loop = do
  z <- getLine
  if null z then return()
    else do
  print $ champ (read z)
  loop

Test details

Test 1

Group: 1

Verdict:

input
1000
582
214
723
273
...

correct output
0
1
7
7
6
...

user output
'0'
'1'
'7'
'7'
'6'
...
Truncated

Error:
code: <stdin>: hGetLine: end of file

Test 2

Group: 2

Verdict:

input
1000
615664
916441
627600
279508
...

correct output
1
2
3
2
2
...

user output
'1'
'2'
'3'
'2'
'2'
...
Truncated

Error:
code: <stdin>: hGetLine: end of file

Test 3

Group: 3

Verdict:

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
'7'
'2'
'2'
'0'
'9'
...
Truncated

Error:
code: <stdin>: hGetLine: end of file