洛谷 1328 生活大爆炸版石头剪刀布——水题

题目:https://www.luogu.org/problemnew/show/P1328

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=205;
int n,na,nb,a[N],b[N],ans,bns,p0,p1;
int f[5][5]=
  {
    0,0,1,1,0,
    1,0,0,1,0,
    0,1,0,0,1,
    0,0,1,0,1,
    1,1,0,0,0
  };
int main()
{
  scanf("%d%d%d",&n,&na,&nb);
  for(int i=1;i<=na;i++) scanf("%d",&a[i]);
  for(int i=1;i<=nb;i++) scanf("%d",&b[i]);
  for(int i=1;i<=n;i++)
    {
      p0++; if(p0>na)p0=1; p1++; if(p1>nb)p1=1;
      ans+=f[a[p0]][b[p1]]; bns+=f[b[p1]][a[p0]];
    }
  printf("%d %d
",ans,bns);
  return 0;
}
原文地址:https://www.cnblogs.com/Narh/p/9641851.html