CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:roni.juntunen
Submission time:2016-10-07 21:21:48 +0300
Language:Java
Status:READY
Result:29
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED19
#30
Test results
testverdicttimegroup
#1ACCEPTED0.17 s1details
#2ACCEPTED0.87 s2details
#30.15 s3details

Code

import java.util.Scanner;

/**
 *
 * @author ronij
 */
public class Bittijono {
        public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int count = input.nextInt();
        int[] lookup = new int[count];
        byte[] table = new byte[count];
        for (int i = 0; i < count; i++) {
            lookup[i] = input.nextInt();
        }
        long[] time = new long[2];
        time[0] = System.currentTimeMillis();
        byte[] source = new byte[1048576];
        int power;
        for (int i = 0; i < 20; i++) {
            power = (int)Math.pow(2,i);
            for (int u = 0; u < power; u++) {
                if (source[u] == 0){
                    source[power + u] = 1;      
                }
                else{
                    source[power + u] = 0;
                }
            }
        }
        for (int i = 0; i < count; i++) {
            table[i] = source[lookup[i] - 1];
        }
        //time[1] = System.currentTimeMillis();
        //System.out.println(Arrays.toString(table));
        for (int i = 0; i < count; i++) {
            System.out.println(table[i]);
        }
        //System.out.println(time[1] - time[0]);
    }
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
100
62
9
12
73
...

correct output
1
1
1
0
1
...

user output
1
1
1
0
1
...

Test 2

Group: 2

Verdict: ACCEPTED

input
100000
565433
141881
120108
825392
...

correct output
1
1
0
0
1
...

user output
1
1
0
0
1
...

Test 3

Group: 3

Verdict:

input
100000
374768524402011755
937067109466254318
389256426086302899
932585725667010169
...

correct output
0
1
1
1
1
...

user output
(empty)

Error:
Exception in thread "main" java.util.InputMismatchException: For input string: "374768524402011755"
	at java.util.Scanner.nextInt(Scanner.java:2123)
	at java.util.Scanner.nextInt(Scanner.java:2076)
	at Bittijono.main(Bittijono.java:14)