➽ Problem:-
https://www.hackerrank.com/challenges/between-two-sets/problem
➽ Solution:-
#include<stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
int x[100], y[100];
for(int i=0; i<a; i++)
{
scanf("%d", &x[i]);
}
for(int i=0; i<b; i++)
{
scanf("%d", &y[i]);
}
int ans = 0;
for(int j=1; j<=100; j++)
{
int temp = 1;
for(int i=0; i<a; i++)
if(j % x[i] != 0)
temp = 0;
for(int i=0; i<b; i++)
if(y[i] % j != 0)
temp = 0;
if(temp==1)
ans++;
}
printf("%d", ans);
return 0;
}
0 Comments
Please do not enter any spam link in the comment section.