Task: | Bittijono |
Sender: | Shrike |
Submission time: | 2016-10-11 08:16:25 +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.18 s | 2 | details |
#3 | ACCEPTED | 0.24 s | 3 | details |
Code
#include <iostream> #include <string> #include <vector> #include <sstream> #include <cmath> typedef long long ll; /* ABBA BAAB BAAB ABBA BAAB ABBA ABBA BAAAB */ using namespace std; ll atol (string c) { stringstream s; ll i; s << c; s >> i; return i; } int solve (ll i) { bool is_a = true; int a[12] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1}; int b[12] = {1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0}; /* if (i == 80) return 0; */ ll max = (ll)pow (4.0, 30.0); for (;;) { // cout << is_a << " " << i << " " << max << endl; if (is_a) { if (i < 12) { return a[i]; } else { if (i < max/4) { is_a = true; max = max/4; } else if (i >= max/4 && i < 2*(max/4)) { is_a = false; max = max/4; i -= max; } else if (i >= 2*(max/4) && i < 3*(max/4)) { is_a = false; max = max/4; i -= 2*max; } else { is_a = true; max = max/4; i -= 3*max; } } } else { if (i < 12) { return b[i]; } else { if (i < max/4) { is_a = false; max = max/4; } else if (i >= max/4 && i < 2*(max/4)) { is_a = true; max = max/4; i -= max; } else if (i >= 2*(max/4) && i < 3*(max/4)) { is_a = true; max = max/4; i -= 2*max; } else { is_a = false; max = max/4; i -= 3*max; } } } } return 0; } int main () { string num_s; ll num, i; cin >> num_s; num = atol (num_s); vector<ll> input(num); for (i = 0; i < num; i++) { num_s = ""; cin >> num_s; input[i] = atol (num_s); } for (i = 0; i < num; i++) cout << solve (input[i]-1) << "\n"; 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 ... |