hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #오각수 #289

Open hwangnk1004 opened 4 years ago

hwangnk1004 commented 4 years ago

import java.util.Scanner;

public class Main { public static void main(String args[]) {

    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    int arr[] = new int[n];
    for (int i = 0; i < n; i++) {
        arr[i] = scanner.nextInt();
        int sum = 0;
        for (int j = 1; j <= 81; j++) {
            if (arr[i] == (3 * j * j - j) / 2) {
                    sum++;
            }

        }

        if (sum >0) {
            System.out.println(arr[i]+" Y");
        } else {
            System.out.println(arr[i]+" N");
        }
    }

}

}