Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[])
- {
- Scanner in = new Scanner(System.in);
- int m = in.nextInt();
- if (in.hasNextLine())
- in.nextLine();
- String i = in.nextLine();
- String t[] = i.split(" ");
- int s = t.length;
- int u[] = new int[s];
- for(int j=0;j<s;j++)
- {
- u[j]=Integer.parseInt(t[j]);
- }
- String res = "";
- for(int j = 1; j <= m; j++)
- {
- if(carreParfait(j) && !inTab(u,j))
- res += j + " ";
- }
- System.out.println(res.equals("")?"None":res.trim());
- }
- public static boolean carreParfait(int x)
- {
- boolean retour = false;
- for(int i = 0; i <= x; i++)
- {
- if(i*i == x)
- retour = true;
- }
- return retour;
- }
- public static boolean inTab(int[] tab, int x)
- {
- boolean retour = false;
- for(int i =0 ; i< tab.length; i++)
- {
- if(tab[i] == x)
- retour = true;
- }
- return retour;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement