#30093: C++解


andrew3321@gmail.com (yungchun huang)

School : No School
ID : 126959
IP address : [163.19.102.169]
Last Login :
2022-05-19 16:42:12
h026. 202001_1 猜拳 -- 2020年1月APCS | From: [163.19.102.169] | Post Date : 2022-04-28 13:55

#include <iostream>

using namespace std;

int main()
{
    int F,N;
    cin >>F>>N;
    int a[N],b[N];

    b[0]=F;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    b[1]=a[0];
    for(int i=2;i<N;i++)b[i]=a[i-1];

    for(int i=2;i<N;i++){
    if(a[i-2]==a[i-1]&&a[i-1]==0)b[i]=5;
    else if(a[i-2]==a[i-1]&&a[i-1]==2)b[i]=0;
    else if(a[i-2]==a[i-1]&&a[i-1]==5)b[i]=2;
    }

    for(int i=0;i<N;i++){
    if(a[i]==0&&b[i]==5){
            cout << b[i]<<" : Won at round "<< i+1 << endl;
            break;}
    if(a[i]==2&&b[i]==0)
    {
        cout << b[i]<<" : Won at round "<< i+1 << endl;
        break;}
    if(a[i]==5&&b[i]==2)
    {
        cout << b[i]<<" : Won at round "<< i+1 << endl;
        break;}
    if(a[i]==5&&b[i]==0)
    {
        cout << b[i]<<" : Lost at round "<< i+1 << endl;
        break;}
    if(a[i]==0&&b[i]==2)
    {
        cout << b[i]<<" : Lost at round "<< i+1 << endl;
        break;}
    if(a[i]==2&&b[i]==5)
    {
        cout << b[i]<<" : Lost at round "<< i+1 << endl;
        break;}

    cout << b[i] << " ";

    }
    if(b[N-1]==a[N-1]){cout <<": Drew at round "<< N << endl;
        }

    return 0;
}

 
ZeroJudge Forum