每日一题洛谷P1328 [NOIP 2014 提高组] 生活大爆炸版石头剪刀布c++

每日一题洛谷P1328 [NOIP 2014 提高组] 生活大爆炸版石头剪刀布c++_第1张图片

#include
using namespace std;
int main() {
	int n, na, nb;
	cin >> n >> na >> nb;
	int a[200] = { 0 };
	int b[200] = { 0 };
	for (int i = 0; i < na; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < nb; i++) {
		cin >> b[i];
	}
	int ca = 0;
	int cb = 0;
	int i = 0;
	int j = 0;
	while(n--){
		if (i >= na)i = 0;
		if (j >= nb)j = 0;
		//赢:ca++;
		//输:cb++;
		int x = a[i];
		int y = b[j];
		if (x == 0) {
			if (y == 1) cb++;
			else if (y == 2)ca++;
			else if (y == 3)ca++;
			else if (y == 4)cb++;
		}
		else if (x == 1) {
			if (y == 0) ca++;
			else if (y == 2)cb++;
			else if (y == 3)ca++;
			else if (y == 4)cb++;
		}
		else if (x == 2) {
			if (y == 0) cb++;
			else if (y == 1)ca++;
			else if (y == 3)cb++;
			else if (y == 4)ca++;
		}
		else if (x == 3) {
			if (y == 0) cb++;
			else if (y == 1)cb++;
			else if (y == 2)ca++;
			else if (y == 4)ca++;
		}
		else if (x == 4) {
			if (y == 0) ca++;
			else if (y == 1)ca++;
			else if (y == 2)cb++;
			else if (y == 3)cb++;
		}
		i++;
		j++;
	}
	cout << ca << " " << cb << endl;
	return 0;
}

每日一题洛谷P1328 [NOIP 2014 提高组] 生活大爆炸版石头剪刀布c++_第2张图片

你可能感兴趣的:(洛谷,生活)