CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:Shrike
Submission time:2016-10-10 10:58:35 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.05 s1details
#20.18 s2details
#30.32 s3details

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[10] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0};
	int b[10] = {1, 0, 0, 1, 0, 1, 1, 0, 0, 1};
	if (i == 80)
		return 0;
	ll max = (ll)pow (4.0, 30.0);
	for (;;) {
		if (is_a) {
			if (i < 10) {
				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 < 10) {
				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:

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:

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:

input
100000
374768524402011755
937067109466254318
389256426086302899
932585725667010169
...

correct output
0
1
1
1
1
...

user output
0
1
1
1
1
...