結果

問題 No.1500 Super Knight
ユーザー ks2mks2m
提出日時 2021-05-07 22:06:27
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 638 bytes
コンパイル時間 3,702 ms
コンパイル使用メモリ 71,668 KB
実行使用メモリ 58,124 KB
最終ジャッジ日時 2023-10-13 13:12:10
合計ジャッジ時間 8,931 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,204 KB
testcase_01 AC 126 ms
56,016 KB
testcase_02 AC 125 ms
55,688 KB
testcase_03 RE -
testcase_04 AC 128 ms
55,636 KB
testcase_05 AC 125 ms
56,024 KB
testcase_06 RE -
testcase_07 AC 125 ms
55,960 KB
testcase_08 AC 125 ms
55,776 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 128 ms
56,168 KB
testcase_13 AC 127 ms
55,780 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 129 ms
55,904 KB
testcase_17 RE -
testcase_18 AC 128 ms
55,912 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 126 ms
56,248 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 127 ms
55,776 KB
testcase_27 RE -
testcase_28 AC 129 ms
55,804 KB
testcase_29 RE -
testcase_30 AC 128 ms
55,768 KB
testcase_31 AC 128 ms
56,116 KB
testcase_32 AC 128 ms
55,820 KB
testcase_33 AC 127 ms
56,140 KB
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int[] a = {1, 12, 65};
		if (n < 3) {
			System.out.println(a[n]);
		} else {
			int mod = 1000000007;
			long x = 6L * n + 1;
			long x1 = x / 2;
			long x2 = x1 + 1;
			x1 %= mod;
			x2 %= mod;
			long v1 = x1 * x2 * 2 % mod;

			long r1 = n / 2;
			long r2 = r1 * (r1 + 1);
			if (n % 2 == 0) {
				r2 -= r1;
				throw new Exception();
			}
			r2 *= 4;
			r2 %= mod;

			long ans = v1 - r2 + mod;
			ans %= mod;
			System.out.println(ans);
		}
	}
}
0