From f172a0d2dbb5b0247a708f660ae52ec14e56e283 Mon Sep 17 00:00:00 2001 From: dnya0 Date: Sun, 18 Jan 2026 23:30:34 +0900 Subject: [PATCH] =?UTF-8?q?[BOJ]=20=EA=B2=8C=EC=9E=84=20/=20=EC=8B=A4?= =?UTF-8?q?=EB=B2=843=20/=2012=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acmicpc.net/problem/1072 --- ahma0/BOJ_1027.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ahma0/BOJ_1027.java diff --git a/ahma0/BOJ_1027.java b/ahma0/BOJ_1027.java new file mode 100644 index 0000000..693a0ec --- /dev/null +++ b/ahma0/BOJ_1027.java @@ -0,0 +1,37 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.StringTokenizer; + +public class Main { + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + int x = Integer.parseInt(st.nextToken()); + int y = Integer.parseInt(st.nextToken()); + int z = getPercent(x, y); + + int ans = -1; + int left = 0; + int right = (int) 1e9; + while (left <= right) { + int mid = (left + right) / 2; + + if (getPercent(x + mid, y + mid) != z) { + ans = mid; + right = mid - 1; + } else { + left = mid + 1; + } + } + System.out.println(ans); + br.close(); + } + + private static int getPercent(int x, int y) { + return (int) ((long) y * 100 / x); + } + +} +