题意是给两组数,求两组数a[],b[]中分别任意相加两个或者几个数的值相等的有多少个
AC代码:
代码语言:javascript复制#include <bits/stdc .h>
using namespace std;
const int MAXN = 1000005;
int a[MAXN],b[MAXN];
int sum1,sum2;
int cnt,n,m;
int main()
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i )
scanf("%d",&a[i]);
for(int j=0;j<m;j )
scanf("%d",&b[j]);
sum1 = 0, sum2 = 0, cnt = 0;
int x = 0, y = 0;
while(x < n || y < m){
if(sum1 > sum2){
sum2 = b[y ];
}
else{
sum1 = a[x ];
}
if(sum1 == sum2){
cnt ;
}
}
printf("%dn",cnt);
return 0;
}