Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- class Test {
- public static void main(String[] args) throws IOException
- {
- Integer i,j;
- Integer T,N;
- Set<Integer> s=new HashSet<Integer>();
- Integer Z1=5000000;
- Integer Z =(int) Math.sqrt(Z1);
- Integer temp;
- for(i=1;i<=Z+1;i++)
- for(j=i+1;j<=Z+1;j++)
- {
- temp=i*i+j*j;
- if(temp<=Z1)
- {
- a.add(temp);
- }
- }
- Reader.init(System.in);
- T= Reader.nextInt();
- while(T-->0)
- {
- N=Reader.nextInt();
- if(a.contains(N))
- System.out.println("YES");
- else
- System.out.println("NO");
- }
- }
- class Reader {
- static BufferedReader reader;
- static StringTokenizer tokenizer;
- /** call this method to initialize reader for InputStream */
- static void init(InputStream input) {
- reader = new BufferedReader(
- new InputStreamReader(input) );
- tokenizer = new StringTokenizer("");
- }
- /** get next word */
- static String next() throws IOException {
- while ( ! tokenizer.hasMoreTokens() ) {
- //TODO add check for eof if necessary
- tokenizer = new StringTokenizer(
- reader.readLine() );
- }
- return tokenizer.nextToken();
- }
- static int nextInt() throws IOException {
- return Integer.parseInt( next() );
- }
- static long nextLong() throws IOException {
- return Long.parseLong( next() );
- }
- static double nextDouble() throws IOException {
- return Double.parseDouble( next() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement