first commit

This commit is contained in:
Nyagami
2022-12-15 23:51:04 +07:00
commit 87d51fb251
292 changed files with 12623 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package nyagami;
import java.util.Scanner;
import java.util.TreeSet;
public class test{
static boolean has(int[] a, int n, int x){
for(int i=0;i<n;i++) if(a[i]==x) return true;
return false;
}
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
TreeSet<Integer> h = new TreeSet<>();
int n = sc.nextInt(), m = sc.nextInt();
int[] a = new int[n];
int[] b = new int[m];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
for(int i=0;i<m;i++){
b[i]=sc.nextInt();
}
for(int i=0;i<n;i++){
if(has(b,m,a[i])){
h.add(a[i]);
}
}
h.forEach((k)->{
System.out.printf("%d ", k);
});
sc.close();
}
}