帮忙看一下吧……
查看原帖
帮忙看一下吧……
255762
lyxleo楼主2020/12/6 21:37

为什么老是出错?

#include <bits/stdc++.h>
using namespace std;
long long n,a_len,b_len;
const int form[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},
};
long long a[205],b[205];
long long a_pos,b_pos;
long long a_ans,b_ans;


int main(){
	scanf("%lld %lld %lld",&n,&a_len,&b_len);
	for(long long i=0;i<a_len;++i){
		scanf("%lld",&a[i]);
	}
	for(long long i=0;i<b_len;++i){
		scanf("%lld",&b[i]);
	}
	for(int i=0;i<n;++i){
		a_pos = i%a_len;
		b_pos = i%b_len;
		if(form[a[a_pos]][b[b_pos]] == 1){
			++a_ans;
		}
		else if(form[a[a_pos]][b[b_pos]] == -1){
			++b_ans;
		} 
	}
	printf("%lld %lld",a_ans,b_ans);
	return 0;
}
2020/12/6 21:37
加载中...