From 76f2e219d8147ad8a33ea55e543ac210e4cdcdb7 Mon Sep 17 00:00:00 2001 From: ShineCorine Date: Wed, 3 Apr 2024 07:53:20 +0900 Subject: [PATCH] =?UTF-8?q?[Solved]=20PRG=5F=EB=A0=88=EB=B2=A82=5F?= =?UTF-8?q?=EB=A7=88=EB=B2=95=EC=9D=98=20=EC=97=98=EB=A6=AC=EB=B2=A0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Jongmin_solved.java" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "Week 17/PRG_\353\240\210\353\262\2502_\353\247\210\353\262\225\354\235\230 \354\227\230\353\246\254\353\262\240\354\235\264\355\204\260/Jongmin_solved.java" diff --git "a/Week 17/PRG_\353\240\210\353\262\2502_\353\247\210\353\262\225\354\235\230 \354\227\230\353\246\254\353\262\240\354\235\264\355\204\260/Jongmin_solved.java" "b/Week 17/PRG_\353\240\210\353\262\2502_\353\247\210\353\262\225\354\235\230 \354\227\230\353\246\254\353\262\240\354\235\264\355\204\260/Jongmin_solved.java" new file mode 100644 index 0000000..5f383a6 --- /dev/null +++ "b/Week 17/PRG_\353\240\210\353\262\2502_\353\247\210\353\262\225\354\235\230 \354\227\230\353\246\254\353\262\240\354\235\264\355\204\260/Jongmin_solved.java" @@ -0,0 +1,25 @@ +class Solution { + public int solution(int storey) { + int answer = 0; + + while(storey != 0){ + int digit = storey%10; + storey = storey/10; + + if(digit == 5){ + if(storey % 10 < 5){ + answer += digit; + }else{ + answer += (10 - digit); + storey += 1; + } + }else if( digit < 5){ + answer += digit; + }else{ + answer += (10-digit); + storey +=1; + } + } + return answer; + } +} \ No newline at end of file