首页 > 代码库 > URAL 1209 1, 10, 100, 1000...

URAL 1209 1, 10, 100, 1000...

省点心,直接列出来了……

 1 import java.util.Arrays; 2 import java.util.Scanner; 3  4 public class P1209 5 { 6     public static void main(String args[]) 7     { 8         long k[] = new long[100000]; 9         for (int i = 1; i < k.length; i++)10             k[i] = (long) i * (i + 1) / 2;11         try (Scanner cin = new Scanner(System.in))12         {13             while (cin.hasNext())14             {15                 int n = cin.nextInt();16                 for (int i = 0; i < n; i++)17                 {18                     long x = cin.nextInt();19                     if (x == 1)20                         System.out.println(1);21                     else if (Arrays.binarySearch(k, x - 1) >= 0)22                         System.out.println(1);23                     else24                         System.out.println(0);25                 }26             }27         }28     }29 }

 

URAL 1209 1, 10, 100, 1000...