๐ ์ฝ๋ฉํ
์คํธ/๋ฐฑ์ค & ํ๋ก๊ทธ๋๋จธ์ค
[SWEA][JAVA]D3 : [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 4์ผ์ฐจ - ๊ฑฐ๋ญ ์ ๊ณฑ
deep_lee
2022. 11. 7. 15:25
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14dUIaAAUCFAYD
SW Expert Academy
SW ํ๋ก๊ทธ๋๋ฐ ์ญ๋ ๊ฐํ์ ๋์์ด ๋๋ ๋ค์ํ ํ์ต ์ปจํ ์ธ ๋ฅผ ํ์ธํ์ธ์!
swexpertacademy.com
๋จ์ํ ๋ฐ๋ณต๋ฌธ์ผ๋ก ์ ๊ทผํ๋ฉด D1 ๊ธ๋ฌธ์ ์ด์ง๋ง
์ถ์ ์๋๋ ์ฌ๊ทํจ์๋ฅผ ์ด์ฉํ๋๊ฒ์ด๊ธฐ๋๋ฌธ์ D3์ธ๊ฒ๊ฐ๋ค.
import java.util.Scanner;
class Solution
{
public static int rec(int x, int y){
if(y==0)
return 1;
return x*rec(x,y-1);
}
public static void main(String args[]) throws Exception
{
Scanner kb = new Scanner(System.in);
for(int t=1; t<=10; t++){
int test=kb.nextInt();
int x=kb.nextInt();
int y=kb.nextInt();
System.out.println("#"+t+" "+rec(x,y));
}
}
}