算法刷题记录:P1328 [NOIP2014 提高组] 生活大爆炸版石头剪刀布

发布时间 2023-06-10 18:18:38作者: 想个昵称好难ABCD

题目链接

https://www.luogu.com.cn/problem/P1328

题目分析

是一道和环有关的问题,直接模拟即可

AC代码

// Problem: P1328 [NOIP2014 提高组] 生活大爆炸版石头剪刀布
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1328
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <iostream>

const int MXN = 205;
int n, an, bn, cnta, cntb;
int w[5][5] = {{2, 0, 1, 1, 0}, {1, 2, 0, 1, 0}, {0, 1, 2, 0, 1}, {0, 0, 1, 2, 1}, {1, 1, 0, 0, 2}};
int A[MXN], B[MXN];

int main()
{
	std::cin >> n >> an >> bn;
	for (int i = 0; i < an; ++ i) std::cin >> A[i];
	for (int i = 0; i < bn; ++ i) std::cin >> B[i];
	for (int i = 0; i < n; ++ i) 
	{
		if (w[A[i % an]][B[i % bn]] == 1) cnta ++ ;
		if (w[A[i % an]][B[i % bn]] == 0)cntb ++ ;
	}
	std::cout << cnta << ' ' << cntb;
}