1 条题解
-
0
C :
#include "stdio.h" void main() { int array1[2][200]={0}; int n,na,nb,a=0,b=0; int i=0; scanf("%d %d %d",&n,&na,&nb); for(i=0;i<na;i++) { scanf("%d",&array1[0][i]); } for(i=0;i<nb;i++) { scanf("%d",&array1[1][i]); } for(i=0;i<n;i++) { if(!(array1[0][i%na]==array1[1][i%nb])){ if(array1[0][(i%na)]==0) { if(array1[1][i%nb]==2||array1[1][i%nb]==3){a++;} else{b++;} } if(array1[0][(i%na)]==1) { if(array1[1][i%nb]==0||array1[1][i%nb]==3){a++;} else{b++;} } if(array1[0][(i%na)]==2) { if(array1[1][i%nb]==1||array1[1][i%nb]==4){a++;} else{b++;} } if(array1[0][(i%na)]==3) { if(array1[1][i%nb]==2||array1[1][i%nb]==4){a++;} else{b++;} } if(array1[0][(i%na)]==4) { if(array1[1][i%nb]==0||array1[1][i%nb]==1){a++;} else{b++;} } } } printf("%d %d",a,b); }
C++ :
#include<cstdio> #include<string> #include<iostream> using namespace std; int n,na,nb; int a[204],b[204]; int main() { int i,j,ansa=0,ansb=0; scanf("%d%d%d",&n,&na,&nb); for(i=1;i<=na;i++) scanf("%d",&a[i]); for(i=1;i<=nb;i++) scanf("%d",&b[i]); for(i=1;i<=n;i++) {int x=a[(i-1)%na+1]; int y=b[(i-1)%nb+1]; if(x==0&&y==1)ansb++; else if(x==1&&y==2)ansb++; else if(x==0&&y==2)ansa++; else if(x==0&&y==3)ansa++; else if(x==1&&y==3)ansa++; else if(x==2&&y==3)ansb++; else if(x==0&&y==4)ansb++; else if(x==1&&y==4)ansb++; else if(x==2&&y==4)ansa++; else if(x==3&&y==4)ansa++; else if(x==1&&y==0)ansa++; else if(x==2&&y==1)ansa++; else if((x==2||x==3)&&y==0)ansb++; else if(x==3&&y==1)ansb++; else if(x==3&&y==2)ansa++; else if(x==4&&(y==0||y==1))ansa++; else if(x==4&&(y==3||y==2))ansb++; } printf("%d %d",ansa,ansb); return 0; }
Pascal :
program ex; var data:array[0..4,0..4] of longint; na,nb,n,i,k,num,la,lb,ansa,ansb:longint; a,b:array[1..200] of longint; begin readln(n,na,nb); for i:=1 to na do begin read(num); a[i]:=num; end; for i:=1 to nb do begin read(num); b[i]:=num; end; for i:=0 to 4 do data[i,i]:=0; data[1,0]:=1; data[2,0]:=2; data[2,1]:=1; data[3,0]:=2; data[3,1]:=2; data[3,2]:=1; data[4,0]:=1; data[4,1]:=1; data[4,2]:=2; data[4,3]:=2; for i:=1 to n do begin inc(la); inc(lb); if la=na+1 then la:=1; if lb=nb+1 then lb:=1; if a[la]=b[lb] then continue; if a[la]>b[lb] then begin if data[a[la],b[lb]]=1 then inc(ansa); if data[a[la],b[lb]]=2 then inc(ansb); end; if a[la]<b[lb] then begin if data[b[lb],a[la]]=1 then inc(ansb); if data[b[lb],a[la]]=2 then inc(ansa); end; end; write(ansa,' ',ansb); end.
- 1
信息
- ID
- 804
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 3
- 已通过
- 1
- 上传者