結果

問題 No.790 ちきんの括弧並べ
ユーザー 37zigen37zigen
提出日時 2020-03-19 00:11:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 41,592 KB
最終ジャッジ日時 2024-05-08 02:53:36
合計ジャッジ時間 4,227 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,592 KB
testcase_01 AC 123 ms
41,384 KB
testcase_02 AC 131 ms
41,296 KB
testcase_03 AC 126 ms
41,304 KB
testcase_04 AC 124 ms
41,548 KB
testcase_05 AC 125 ms
41,296 KB
testcase_06 AC 124 ms
41,400 KB
testcase_07 AC 110 ms
41,424 KB
testcase_08 AC 112 ms
41,180 KB
testcase_09 AC 125 ms
41,400 KB
testcase_10 AC 120 ms
41,116 KB
testcase_11 AC 124 ms
41,112 KB
testcase_12 AC 125 ms
41,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	long comb(long n,long k) {
		long ret=1;
		for(long i=n;i>=n-k+1;--i)ret*=i;
		for(long i=1;i<=k;++i)ret/=i;
		return ret;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		System.out.println(comb(2*n,n)-comb(2*n,n-1));
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0