백준 1676번
import java.util.Scanner;
public class problem465 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int result = 0;
while (num >= 5) {
result += num / 5;
num /= 5;
}
System.out.println(result);
}
}
백준 17087번
import java.util.Arrays;
import java.util.Scanner;
public class problem466 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = in.nextInt(); // 동생 수
int stay = in.nextInt(); // 내 위치
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
int a = in.nextInt();
arr[i] = Math.abs(a - stay); // 내위치와 동생의 위치 절대값
}
Arrays.sort(arr);
// 2 4 8
int first = arr[0];
for (int i = 1; i < arr.length; i++) {
first = gcd(first, arr[i]); // 최소 공배수 찾기
}
System.out.println(first);
}
static int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
}
백준 1373번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class problem467 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
// 2진수 -> 10진수
BigInteger integer = new BigInteger(br.readLine(), 2);
// 10진수 -> 8진수
System.out.println(integer.toString(8));
}
}
백준 1212번
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader
(new InputStreamReader(System.in));
BigInteger integer = new BigInteger(br.readLine(), 8);
System.out.println(integer.toString(2));
}
}