public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long numberOfCases = scanner.nextInt();
for (long i = 0; i < numberOfCases; i++) {
scanner.nextInt();
long casePower = scanner.nextInt();
long caseY = scanner.nextInt();
long caseX = scanner.nextInt();
long result = fac(caseY) / fac(caseY - caseX) / fac(caseX) * (long) Math.pow(casePower, caseY - caseX);
System.out.println((i + 1) + " " + result);
}
scanner.close();
}
public static long fac(long number) {
if (number > 1) {
return number * fac(number - 1);
} else {
return 1;
}
}
Main class과 패키지는 이름이 이전 대전 때 풀던 것이라 임의로 생략했습니다.