U E D R , A S I H C RSS

ACM_ICPC/Problems/6472

조영준

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과 패키지는 이름이 이전 대전 때 풀던 것이라 임의로 생략했습니다.
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:20
Processing time 0.0088 sec