CSES - Datatähti 2017 alku - Results
Submission details
Task:Bittijono
Sender:Hupijekku
Submission time:2016-10-05 21:15:44 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:25:19: error: 'count' is not a member of 'std'
   int countOnes = std::count(bits.begin(), bits.end(), 1);
                   ^

Code

#include <iostream>
#include <vector>

std::vector<int> bits;

void ToBinary(int n)
{
	if (n / 2 != 0) {
		ToBinary(n / 2);
	}
	bits.push_back(n % 2);
}

int main()
{
	std::vector<int> answers;
	long long input;
	std::cin >> input;
	long long bitPlace;
	for (int i = 0; i < input; i++)
	{
		bits.clear();
		std::cin >> bitPlace;
		ToBinary(bitPlace - 1);
		int countOnes = std::count(bits.begin(), bits.end(), 1);
		if (countOnes % 2) answers.push_back(1);
		else answers.push_back(0);
	}
	for (unsigned int i = 0; i < answers.size(); i++)
	{
		std::cout << answers[i] << '\n';
	}
    return 0;
}