码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-08-26 08:33:55      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   java   for   ar   div   log   sp   

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

 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                     else
24                         System.out.println(0);
25                 }
26             }
27         }
28     }
29 }

 

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

标签:style   blog   color   java   for   ar   div   log   sp   

原文地址:http://www.cnblogs.com/gwhahaha/p/3936361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!