1 solutions

  • 0
    @ 2023-11-29 20:11:06
    #include <bits/stdc++.h>
    using namespace std;
    int cmp(char a , char b){//剪刀0,石头1,布2,蜥蜴人3,斯波克4。 
    	int end;
    	if(a == '0'){
    		if(b == '0'){
    			end = 0;
    		}else if(b == '1'){
    			end = -1;
    		}else if(b == '2'){
    			end = 1;
    		}else if(b == '3'){
    			end = 1;
    		}else if(b == '4'){
    			end = -1;
    		}
    	}
    	if(a == '1'){
    		if(b == '0'){
    			end = 1;
    		}else if(b == '1'){
    			end = 0;
    		}else if(b == '2'){
    			end = -1;
    		}else if(b == '3'){
    			end = 1;
    		}else if(b == '4'){
    			end = -1;
    		}
        }
        if(a == '2'){
    		if(b == '0'){
    			end = -1;
    		}else if(b == '1'){
    			end = 1;
    		}else if(b == '2'){
    			end = 0;
    		}else if(b == '3'){
    			end = -1;
    		}else if(b == '4'){
    			end = 1;
    		}
        }
       	if(a == '3'){
        	if(b == '0'){
    			end = -1;
    		}else if(b == '1'){
    			end = -1;
    		}else if(b == '2'){
    			end = 1;
    		}else if(b == '3'){
    			end = 0;
    		}else if(b == '4'){
    			end = 1;
    		}
        }
       	if(a == '4'){
    		if(b == '0'){
    			end = 1;
    		}else if(b == '1'){
    			end = 1;
    		}else if(b == '2'){
    			end = -1;
    		}else if(b == '3'){
    			end = -1;
    		}else if(b == '4'){
    			end = 0;
    		}
        }
        return (end);
    }
    
    int main()
    {
    	char a[100005] , b[100005];
    	int n;//猜拳次数。 
    	int t1 , t2;//两者的周期。
    	cin >> n >> t1 >> t2;
    	for(int i = 1 ;i <= t1 ;i++){
    		cin >> a[i];
    	}
    	for(int i = 1 ;i <= t2 ;i++){
    		cin >> b[i];
    	}
    	int s = 1;//用于复制周期。 
    	for(int i = 1 ;i <= n ;i++){
    		if(s > t1){
    			s -= t1;//超过周期后出现赋值。 
    		}
    		a[i] = a[s];
    		s++;
    	}
    	s = 1;
    	for(int i = 1 ;i <= n ;i++){
    		if(s > t2){
    			s -= t2;//超过周期后出现赋值。 
    		}
    		b[i] = b[s];
    		s++;
    	}
    	int compare;
    	int win1 = 0;//记录小A的胜利次数。 
    	int win2 = 0;//记录小B的胜利次数。 
    	for(int i = 1 ;i <= n ;i++){
    		compare = cmp(a[i] , b[i]);//函数比较谁胜利。 
    		if(compare == 1){
    			win1++;
    		}else if(compare == -1){
    			win2++;
    		}
    	}
    	cout << win1 << " " << win2;
    	return 0;
    }
    
    • 1

    Information

    ID
    6817
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    9
    Tags
    # Submissions
    7
    Accepted
    5
    Uploaded By