CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:e^(pi*i)=-1
Submission time:2016-10-07 21:40:35 +0300
Language:Java
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED10
#2ACCEPTED19
#3ACCEPTED71
Test results
testverdicttimegroup
#1ACCEPTED0.15 s1details
#2ACCEPTED1.25 s2details
#3ACCEPTED1.24 s3details

Code

import java.util.Scanner;

public class Bittijono
{
    public static void main(String args[])
    {
        Scanner inputTaker = new Scanner(System.in);
        int times = inputTaker.nextInt();
        
        long[] placesOfBits = new long[times];
        
        for(int i = 0; i < times; i++)
        {
            placesOfBits[i] = inputTaker.nextLong();
        }
        
        for(int i = 0; i < times; i++)
        {
            printNumberAtK(placesOfBits[i]);
        }
    }
    
    public static void printNumberAtK(long k)
    {
        int amountOfExponents = 0;
        int lastExponent;
        for(int i = 0; true; i++)
        {
            int exponent = (int) (Math.log(k) / Math.log(2));
            k -= (long) (Math.pow(2, exponent));
            amountOfExponents++;
            if(k == 0)
            {
                lastExponent = exponent;
                break;
            }
        }
        int numberAtK = lastExponent % 2;
        if(amountOfExponents % 2 == 0)
        {
            if(numberAtK == 0) numberAtK = 1;
            else numberAtK = 0;
        }
        System.out.println(numberAtK);
    }
}

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: ACCEPTED

input
100000
374768524402011755
937067109466254318
389256426086302899
932585725667010169
...

correct output
0
1
1
1
1
...

user output
0
1
1
1
1
...