Task: | Bittijono |
Sender: | cattes |
Submission time: | 2016-10-07 18:10:48 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | ACCEPTED | 19 |
#3 | ACCEPTED | 71 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1 | details |
#2 | ACCEPTED | 0.09 s | 2 | details |
#3 | ACCEPTED | 0.12 s | 3 | details |
Compiler report
input/code.cpp: In function 'int getBit(long long unsigned int*, int)': input/code.cpp:15:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses] tmp = tmp >> shift + (8 - shift-1); ^
Code
//#include <stdio.h> #include <iostream> #include <sstream> #include <cstring> #include <math.h> int getBit(unsigned long long * source, int bit) { unsigned char * ptr = (unsigned char *)source; unsigned int byte = bit / 8; unsigned int shift = bit - byte * 8; unsigned char tmp = *(ptr + byte); tmp = tmp << shift; tmp = tmp >> shift + (8 - shift-1); return tmp; } int main() { int numQueries; std::cin >> numQueries; std::cin.get(); unsigned long long * queries = new unsigned long long[numQueries]; for (int i = 0; i < numQueries; i++) { std::cin >> queries[i]; queries[i]--; std::cin.get(); } for (int i = 0; i < numQueries; i++) { int bitsUp = 0; for (int x = 0; x < 64; x++) { if (getBit(&queries[i], x) == 1) { bitsUp++; } } if (bitsUp % 2 == 0) { std::cout << "0\n"; } else { std::cout << "1\n"; } } std::cin.get(); return 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: ACCEPTED
input |
---|
100000 374768524402011755 937067109466254318 389256426086302899 932585725667010169 ... |
correct output |
---|
0 1 1 1 1 ... |
user output |
---|
0 1 1 1 1 ... |