結果

問題 No.535 自然数の収納方法
ユーザー 37zigen37zigen
提出日時 2017-06-24 03:31:13
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,154 bytes
コンパイル時間 3,360 ms
コンパイル使用メモリ 78,300 KB
実行使用メモリ 748,148 KB
最終ジャッジ日時 2024-04-14 21:37:25
合計ジャッジ時間 23,521 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
54,012 KB
testcase_01 AC 130 ms
54,308 KB
testcase_02 AC 1,624 ms
63,408 KB
testcase_03 AC 134 ms
54,724 KB
testcase_04 AC 302 ms
56,112 KB
testcase_05 AC 582 ms
59,120 KB
testcase_06 AC 1,247 ms
59,012 KB
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 AC 1,804 ms
63,136 KB
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 133 ms
54,188 KB
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		long t = System.currentTimeMillis();
		new Main().run();
		// new Thread(null, new Main(), "",
		// Runtime.getRuntime().maxMemory()).start();
		System.err.println(System.currentTimeMillis() - t);
	}

	long MODULO = 1_000_000_000 + 7;

	@SuppressWarnings("unchecked")
	public void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[][][] f = new long[N + 1][N + 1][N];
		for (int i = 1; i <= N; ++i) {
			f[i][i][0] = 1;
		}
		for (int t = 1; t < N; ++t) {
			for (int a1 = 1; a1 <= N; ++a1) {
				for (int nak = 1; nak <= N; ++nak) {
					for (int x = 1; x <= Math.min(nak + t - 1, N); ++x) {
						f[a1][nak][t] += f[a1][x][t - 1];
						f[a1][nak][t] %= MODULO;
					}
				}
			}
		}
		long ans = 0;
		for (int a0 = 1; a0 <= N; ++a0) {
			for (int nak = 1; nak <= N; ++nak) {
				if (nak < a0 + 1) {
					ans = (ans + f[a0][nak][N - 1]) % MODULO;
				}
			}
		}
		System.out.println(ans);
	}

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