UVa Online Judge Challenge "10110"

Published: October 5, 2017 | Last Modified: May 2, 2025

Tags: uva coding challenge

Categories: Java

Problem

My Solution

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {

			boolean light = true;
			long n = sc.nextLong();

			if (n == 0) {
				System.exit(0);
			}

			long a = Math.round(Math.sqrt(n));

			if ((a * a) == n) {
				light = true;
			} else {
				light = false;
			}

			if (light) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}

		}
	}
}