From b3a5368d34e596ce5730a6f5507485a9be23d8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=88=98=EB=AF=BC?= Date: Mon, 13 Jan 2025 09:42:46 +0900 Subject: [PATCH] CT_359 --- ...\353\271\227\355\206\240\354\250\251.java" | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 "BOJ/Java/src/S4/Boj_28086_\353\257\270\354\206\214\353\205\200\354\273\264\355\223\250\355\204\260\355\214\214\353\243\250\353\271\227\355\206\240\354\250\251.java" diff --git "a/BOJ/Java/src/S4/Boj_28086_\353\257\270\354\206\214\353\205\200\354\273\264\355\223\250\355\204\260\355\214\214\353\243\250\353\271\227\355\206\240\354\250\251.java" "b/BOJ/Java/src/S4/Boj_28086_\353\257\270\354\206\214\353\205\200\354\273\264\355\223\250\355\204\260\355\214\214\353\243\250\353\271\227\355\206\240\354\250\251.java" new file mode 100644 index 0000000..66258d6 --- /dev/null +++ "b/BOJ/Java/src/S4/Boj_28086_\353\257\270\354\206\214\353\205\200\354\273\264\355\223\250\355\204\260\355\214\214\353\243\250\353\271\227\355\206\240\354\250\251.java" @@ -0,0 +1,50 @@ +package S4; + +import java.io.*; + +public class Boj_28086_미소녀컴퓨터파루빗토쨩 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + StringBuilder num1 = new StringBuilder(); + StringBuilder num2 = new StringBuilder(); + + char[] chars = br.readLine().toCharArray(); + num1.append(chars[0]); + + char order = '0'; + int idx = 1; + + while (idx < chars.length) { + if (chars[idx] == '+' + || chars[idx] == '-' + || chars[idx] == '*' + || chars[idx] == '/') { + order = chars[idx++]; + break; + } + num1.append(chars[idx++]); + } + + while (idx < chars.length) { + num2.append(chars[idx++]); + } + + long n1 = Long.parseLong(num1.toString(), 8); + long n2 = Long.parseLong(num2.toString(), 8); + + if (order == '+') { + bw.write(Long.toString(n1 + n2, 8)); + } else if (order == '-') { + bw.write(Long.toString(n1 - n2, 8)); + } else if (order == '*') { + bw.write(Long.toString(n1 * n2, 8)); + } else { + bw.write(n2 == 0 ? "invalid" + : Long.toString((long) Math.floor((double) n1 / (double) n2), 8)); + } + + bw.flush(); + } +}