백준 6502번 (Bronze 2)
import java.util.Scanner;
public class problem318 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int count = 0;
while (true) {
double sum = 0;
double r = in.nextDouble(); // 식탁의 반지름
if (r == 0) {
break;
}
double w = in.nextDouble(); // 피자의 너비
sum += Math.pow(w, 2);
double l = in.nextDouble(); // 피자의 높이
sum += Math.pow(l, 2);
r *= 2; // 식탁의 넓이
count++;
// sum = 사각형의 대각선의 길이,
// 가로(너비) 제곱 + 세로(높이)의 제곱의 루트 (Math.sqrt)
if (r >= Math.sqrt(sum)) {
System.out.println("Pizza " + count +
" fits on the table.");
} else {
System.out.println("Pizza " + count +
" does not fit on the table.");
}
}
}
}
백준 6679번 (Bronze 2)
import java.util.Scanner;
public class problem319 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
for (int i = 2992; i <= 9999; i++) {
int temp = i;
int a = 0; // 10진수의 누적합 변수
int b = 0; // 12진수의 누적합 변수
int c = 0; // 16진수의 누적합 변수
while (temp > 0) {
a += temp % 10;
temp /= 10;
}
temp = i; // i로 다시 초기화
while (temp > 0) {
b += temp % 12;
temp /= 12;
}
temp = i; // i로 다시 초기화
while (temp > 0) {
c += temp % 16;
temp /= 16;
}
if (a == b && b == c) {
System.out.println(i);
}
}
}
}
백준 7600번 (Bronze 2)
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class problem320 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (true) {
String str = in.nextLine();
// 탈출 조건
if (str.equals("#")) {
break;
}
// 문자 중복 제거를 위한 set 객체
Set<Character> set = new HashSet<>();
for (char c : str.toCharArray()) {
// isLetter : c가 문자 인지 확인
if (Character.isLetter(c)) {
set.add(Character.toLowerCase(c));
}
}
System.out.println(set.size());
}
}
}