Task: | Bittijono |
Sender: | e^(pi*i)=-1 |
Submission time: | 2016-10-07 21:40:35 +0300 |
Language: | Java |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | ACCEPTED | 19 |
#3 | ACCEPTED | 71 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.15 s | 1 | details |
#2 | ACCEPTED | 1.25 s | 2 | details |
#3 | ACCEPTED | 1.24 s | 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)); 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 ... |