---
# System prepended metadata

title: '【題解】h026: 202001_1 猜拳'
tags: [Zerojudge]

---

###### tags: `Zerojudge`
【題解】h026: 202001_1 猜拳
===
Posted on 2022/4/23 | By : Victoria1103
【題目敘述】https://zerojudge.tw/ShowProblem?problemid=h026



```cpp=
#include <iostream> 
using namespace std; 
int main () 
{ 	
    int f , n; 
    cin >> f; 
    cin >> n; 
    int A[n]; 	
    int count=0; 
    for (int i=1 ; i<=n ; i++){ 		
        cin >> A[i]; 	
    	} 	
    for (int i=1 ; i<=n ; i++){ 		
        if (f==0){ 			
        	if (A[i]==2){ 			
        		cout << f << " : Won at round " << i << endl; 		
        		count=0; 				
        		break;			 			
    			} 			
        	if (A[i]==5){ 				
        		cout << f << " : Lost at round " << i << endl;
        		count=0;
       			break; 			
    			} 			
        	if (A[i]==0){ 				
        	cout << f << " "; 			
        	count++; 			
        		if (count==n){ 				
        			cout << ": Drew at round " << i << endl;		 
        			count=0;		 				
        			break;
    				}else if (count%2==0){
        				f=5;   
    					}else if (count%2!=0){
        					f=0;
							}		 		
  				} 
			}
    else if (f==2){
        if (A[i]==0){
        	cout << f << " : Lost at round " << i << endl;
        	count=0;		 				
        	break;
    	}
        if (A[i]==5){
        	cout << f << " : Won at round " << i << endl; 		
        	count=0; 				
        	break;
    		}
        if (A[i]==2){
        	cout << f << " "; 			
        	count++; 			
        	if (count==n){ 				
        		cout << ": Drew at round " << i << endl;		 
        		count=0;		 				
        		break;
    			}else if (count%2==0){
        			f=0;
					}else if (count%2!=0){
        				f=2;
						}
   			}
		}
        else if (f==5){
        	if (A[i]==0){
        		cout << f << " : Won at round " << i << endl; 		
        		count=0; 				
        		break;
    		}
        	if (A[i]==2){
        		cout << f << " : Lost at round " << i << endl;
        		count=0;		 				
        		break;
    		}
        	if (A[i]==5){
        		cout << f << " "; 			
        		count++; 			
        		if (count==n){
        			cout << ": Drew at round " << i << endl;		 
        			count=0;		 				
        			break;
    			}else if (count%2==0){
        			f=2;
    				}else if (count%2!=0){
        				f=5;
    					}
   				}
  			}       
 	}
    return 0; 		 	 		 	
}