石头剪刀布,模拟

#include "bits/stdc++.h"
using namespace std;
int win[5][5] = {
        {0, -1, 1, 1, -1},
        {1, 0, -1, 1, -1},
        {-1, 1, 0, -1, 1},
        {-1, -1, 1, 0, 1},
        {1, 1, -1, -1, 0}
};
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    vector<int> A(a);
    vector<int> B(b);
    for(int i = 0;i<a;i++){
        cin>>A[i];
    }
    for(int i = 0;i<b;i++){
        cin>>B[i];
    }
    int countA = 0,countB = 0;
    for(int i = 0;i<n;i++){
        int a1 = A[i%a] ,b1 = B[i%b];
        if (win[a1][b1] == 1) {
            countA++;
        } else if (win[a1][b1] == -1) {
            countB++;
        }
    }
    cout<<countA<<&quot; &quot;<<countB<<endl;
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务