| Task: | Bittijono |
| Sender: | e^(pi*i)=-1 |
| Submission time: | 2016-10-07 21:14:50 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | 29 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 10 |
| #2 | ACCEPTED | 19 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.15 s | 1 | details |
| #2 | ACCEPTED | 1.32 s | 2 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 3 | details |
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) + 0.000000000000000000000000000001);
k -= (int) (Math.pow(2, exponent) + 0.000000000000000000000000000001);
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: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 374768524402011755 937067109466254318 389256426086302899 932585725667010169 ... |
| correct output |
|---|
| 0 1 1 1 1 ... |
| user output |
|---|
| (empty) |
