Submission #1408998


Source Code Expand

#include<bits/stdc++.h>

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;

lint combi[51][51];
lint my_pow(lint a, lint b) { //a^b
	lint ret = 1;
	while (b != 0) {
		if (b % 2 == 0) {
			a = a*a;
			b /= 2;
		}
		else {
			ret = ret * a;
			b--;
		}
	}
	return ret;
}

int main(void) {
	combi[0][0] = 1;
	for (int i = 0; i <= 50; i++) {
		combi[i][0] = 1;
		combi[i][i] = 1;
		for (int j = 1; j < i; j++) {
			combi[i][j] = combi[i - 1][j] + combi[i - 1][j - 1];
		}
	}
	int N, P;
	scanf("%d %d", &N, &P);
	int hol = 0, jak = 0;
	for (int i = 1; i <= N; i++) {
		int temp;
		scanf("%d", &temp);
		if (temp % 2 == 0) {
			jak++;
		}
		else {
			hol++;
		}
	}

	lint ans = my_pow(2, jak);
	lint temp = 0;

	if (P % 2 == 1) {
		for (int i = 1; i <= hol; i += 2) {
			temp += combi[hol][i];
		}
	}
	else {
		for (int i = 0; i <= hol; i += 2) {
			temp += combi[hol][i];
		}
	}

	ans *= temp;

	printf("%lld", ans);

	return 0;
}

Submission Info

Submission Time
Task A - Biscuits
User skdudn321
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1021 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &P);
                        ^
./Main.cpp:38:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &temp);
                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 16
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt, sample4.txt
All sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
in1.txt AC 1 ms 256 KB
in2.txt AC 1 ms 256 KB
in3.txt AC 1 ms 256 KB
in4.txt AC 1 ms 256 KB
in5.txt AC 1 ms 256 KB
in6.txt AC 1 ms 256 KB
in7.txt AC 1 ms 256 KB
in8.txt AC 1 ms 256 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB
sample4.txt AC 1 ms 256 KB