| Task: | Kyselyt |
| Sender: | Minna Vuorinen |
| Submission time: | 2017-10-11 19:57:23 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.21 s | 1 | details |
| #2 | WRONG ANSWER | 0.28 s | 2 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.math.*;
import java.util.Scanner;
public class kyselyt {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int amountOfCases = Integer.parseInt(in.nextLine());
for (int i = 0; i < amountOfCases; i++) {
System.out.println(performFunction(new BigInteger (in.nextLine())));
}
in.close();
}
public static BigInteger performFunction (BigInteger position) {
int j = 0;
for (j = 0; ((9 * (j + 2) * (int) Math.pow(10, j + 1) - (int) Math.pow(10, j + 2) + 2) / 9) < position.intValue(); j++);
BigInteger length = new BigInteger(String.valueOf(j));
position.subtract(BigInteger.valueOf((9 * (length.intValue() + 1) * ((int) Math.pow(10, length.intValue())) - ((int) Math.pow(10, length.intValue() + 1)) + 1) / 9));
BigInteger number = BigInteger.valueOf((int) Math.pow(10, length.intValue() - 1) + (position.intValue() - 1) / length.intValue());
return BigInteger.valueOf((position.intValue() % length.intValue() == 0) ? number.intValue() % 10 : (number.intValue() / ((int) Math.pow(10, length.intValue() - position.intValue() % length.intValue()))) % 10);
}
}
Test details
Test 1
Group: 1
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 582 214 723 273 ... |
| correct output |
|---|
| 0 1 7 7 6 ... |
| user output |
|---|
| 0 6 7 4 9 ... Truncated |
Error:
Exception in thread "main" java.lang.ArithmeticException: / by zero at kyselyt.performFun...
Test 2
Group: 2
Verdict: WRONG ANSWER
| input |
|---|
| 1000 615664 916441 627600 279508 ... |
| correct output |
|---|
| 1 2 3 2 2 ... |
| user output |
|---|
| 3 9 9 6 2 ... Truncated |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 1000 672274832941907421 260504693279721732 646999966092970935 100853063389774434 ... |
| correct output |
|---|
| 7 2 2 0 9 ... |
| user output |
|---|
| (empty) |
