Task: | Kyselyt |
Sender: | Kisse |
Submission time: | 2017-10-12 00:09:23 +0300 |
Language: | Java |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 25 |
#3 | ACCEPTED | 63 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.30 s | 1 | details |
#2 | ACCEPTED | 0.28 s | 2 | details |
#3 | ACCEPTED | 0.24 s | 3 | details |
Code
import java.util.Scanner; public class Kyselyt { public static void main(String[] args) { Scanner input = new Scanner(System.in); int q = input.nextInt(); for (int i = 0; i < q; i++) { Long index = input.nextLong(); if (index < 10) { System.out.println(index); } else { long base = 10; long len = 2; while (true) { if (index < base) { len = len - 1; base = base - (9 * len * (long) Math.pow(10, len - 1)); break; } base = base + (9 * len * (long) Math.pow(10, len - 1)); len = len + 1; } //System.out.println("Base: " + base + ", Length: " + len); Long diff = (index - base); //System.out.println("Diff: " + diff); Long pos = (diff % len); //System.out.println("Position: " + (pos + 1) + "/" + len); Long step = len * (long) Math.pow(10, len - pos - 1); //System.out.println("Step: " + step); if (pos == 0) { System.out.println((1 + Math.floorDiv(diff, step)) % 10); } else { System.out.println((Math.floorDiv(diff, step)) % 10); } } } } }
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 |