|
|
back to boardHelp!I can not figure out about the limited time. Posted by Hunter 20 Apr 2016 20:09 import java.util.Scanner; public class Digitals { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int a[] = new int[N]; int b[] = new int[N]; int sum = 0; for (int i = 0; i < N; i++) { a[i] = in.nextInt(); sum = 1; for (int j = 0;; j++) { sum = sum + j; if (sum == a[i]) { b[i] = 1; break; } if (sum > a[i]) { b[i] = 0; break; } } } for (int p = 0; p < N - 1; p++) System.out.print(b[p] + " "); System.out.println(b[N - 1]); in.close(); } } |
|
|