File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,5 @@ public static void main(String[] args) {
2323 System .out .println (gameOfStones (10 )+", ans: First" ); //1.428...
2424 System .out .println (gameOfStones (13 )+", ans: First" ); //1.857...
2525 System .out .println (gameOfStones (14 )+", ans: Second" ); //2
26-
27-
2826 }
2927}
Original file line number Diff line number Diff line change 1+ package hackerrank ;
2+
3+ public class TowerBreakers {
4+
5+ static int towerBreakers (int n , int m ) {
6+ // μλ κ²μκ·μΉμ μ μ©νμ¬ μ²«λ²μ§Έ νλ μ΄μ΄κ° μΉμλ©΄ 1μ, λλ²μ§Έ νλ μ΄μ΄κ° μΉμλ©΄ 2λ₯Ό 리ν΄νλ λ¬Έμ
7+ // nκ°μ νμκ° μκ³ κ° νμμ λμ΄λ mμ΄λ€.
8+ // λμκ°λ©΄μ κ²μμ μ§ννλ©°, νλ μ΄μ΄λ λμ΄xμ νμλ₯Ό μ ννμ¬ κΈΈμ΄ yλ§νΌμ μ κ±°ν μ μλ€.
9+ // μ΄λ 1 <= y < xμ΄κ³ x%y = 0μ΄λ€.
10+
11+ //νμκ°
12+ if (m == 1 ) {
13+ return 2 ;
14+ }
15+
16+ if (n % 2 == 0 ) {
17+ return 2 ;
18+ } else {
19+ return 1 ;
20+ }
21+ }
22+
23+ public static void main (String [] args ) {
24+ System .out .println (towerBreakers (2 , 6 ) + ". ans: 2" );
25+ System .out .println (towerBreakers (2 , 2 ) + ". ans: 2" );
26+ System .out .println (towerBreakers (1 , 4 ) + ". ans: 1" );
27+ }
28+ }
You canβt perform that action at this time.
0 commit comments