Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by thai ( 5 years ago )
#include<stdio.h>
#include<stdlib.h>
void nhap(int a[], int n){
for(int i =0; i <=n; i++) scanf("%d", &a[i]);
}
int* multiply(int a1[], int a2[], int m, int n){
int*prod = (int*)malloc((m+n-1)*sizeof(int));
for(int i = 0; i<= m+n-1;i++){
prod[i] =0;
}
for(int i =0 ; i<= m;i++){
for(int j =0; j<= n;j++) prod[i+j]+=a1[i]*a2[j];
}
return prod;
}
//void print(int a3[], int n){
// for(int i =0; i<= n; i++){
// printf("%d", a3[i]);
// if(i!=0) printf("x^%d", i);
// if(i!=n) printf(" + ");
// }
//}
int x0r(int a[], int n){
int t = a[0];
for(int i = 1; i<=n; i++){
t=t^a[i];
}
return t;
}
int main(){
int n, m;
scanf("%d", &n);
int *a1 = (int*)malloc(n*sizeof(int));
nhap(a1,n);
scanf("%d", &m);
int *a2 = (int*)malloc(m*sizeof(int));
nhap(a2,m);
int *prod = multiply(a1,a2,n,m);
// print(prod,n+m);
printf("%d", x0r(prod, n+m));
return 0;
}
Revise this Paste
Parent: 116123