Skip to content

Instantly share code, notes, and snippets.

@JoeUnsung
Created December 17, 2016 17:57
Show Gist options
  • Save JoeUnsung/9ce7c4028ec15d5897455a2201c8c8d8 to your computer and use it in GitHub Desktop.
Save JoeUnsung/9ce7c4028ec15d5897455a2201c8c8d8 to your computer and use it in GitHub Desktop.
Check the number whether complete number or not.
import java.util.*;
import java.io.*;
class Main {
public static int checkCompleteNum(int num){
// 숫자가 완전제곱수인지를 체크하는 메서드 작성.
for(int i = 0 ; i < num ; i++){
if ( num == i*i ){
return 1;
}
}
return 0;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String num1 = sc.next();
String num2 = sc.next();
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
//System.out.println(num1 + " " + num2); // 입력 체크
int cnt = 0;
for (int i = a ; i <= b ; i++){
cnt += checkCompleteNum(i);
}
System.out.println(cnt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment