You are on page 1of 5

294.

#include <iostream>
using namespace std;
int n,v[101],i,ogl,cif,copie,a;
int main()
{
cin>>n;
for(i=1;i<=n;i++)
cin>>v[i];
ogl=0;
copie=v[1];
while(copie>0)
{
ogl=ogl*10+copie%10;
copie=copie/10;
}
a=0;
for (i=2; i<=n; i++)
if(v[i]==ogl)
a=1;
if(a==1)
cout<<"DA";
else
cout<<"NU";
return 0;
}

507.

#include <iostream>
using namespace std;
int n,m,x[1000],y[1000],i,j,k;
int main()
{
cin>>n;
for(i=1; i<=n; i++)
cin>>x[i];
cin>>m;
for(j=1; j<=m; j++)
cin>>y[j];
for(j=1; j<=m; j++)
{
k=0;
for(i=1; i<=n; i++)
{
if(y[j]==x[i])
k++;
}
if(k>=1)
cout<<"1 ";
else
cout<<"0 ";
}
return 0;

508.

#include <iostream>

using namespace std;

int main()

int n;

cin >> n;

int a[25001];
for(int i = 1; i <= n; ++i)

cin >> a[i];

int m, x;

cin >> m;

for(int i = 1; i <= m; ++i)

cin >> x;

int st = 1, dr = n;

bool ok = false;

while(st <= dr)

int mij = (st + dr) / 2;

if(a[mij] == x)

ok = true;

break;

else if(a[mij] < x)

st = mij + 1;

else

dr = mij - 1;

if(ok)

cout << 1 << ' ';

else

cout << 0 << ' ';

return 0;

}
2644.

#include<fstream>

#include<cmath>

using namespace std;

ifstream cin("clase.in");

ofstream cout("clase.out");

int main()

int n,m;

long long a[10001];

cin>>n;

for( int i=1; i<=n; i++)

cin>>a[i];

cin>>m;

long long x;

int cnt=0;

for( int i=1; i<=m; i++)

cin>>x;

int st=1, dr=n;

bool ok=false;

while(st <=dr)

int mij=(st+dr)/2;

if(a[mij]==x)

ok=true;

break;

}
else

if(a[mij]<x)

st=mij+1;

else

dr=mij-1;

if(ok)

cnt++;

cout<<cnt;

return 0;

You might also like