結果

問題 No.1500 Super Knight
ユーザー ks2mks2m
提出日時 2021-05-07 22:09:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 3,479 ms
コンパイル使用メモリ 73,812 KB
実行使用メモリ 56,420 KB
最終ジャッジ日時 2023-10-13 13:15:41
合計ジャッジ時間 9,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
55,984 KB
testcase_01 AC 104 ms
54,028 KB
testcase_02 AC 103 ms
55,724 KB
testcase_03 AC 105 ms
55,720 KB
testcase_04 AC 103 ms
53,900 KB
testcase_05 AC 103 ms
55,932 KB
testcase_06 AC 102 ms
56,420 KB
testcase_07 AC 102 ms
56,112 KB
testcase_08 AC 101 ms
56,144 KB
testcase_09 AC 101 ms
55,964 KB
testcase_10 AC 101 ms
55,912 KB
testcase_11 AC 101 ms
55,880 KB
testcase_12 AC 102 ms
55,656 KB
testcase_13 AC 103 ms
55,944 KB
testcase_14 AC 103 ms
55,756 KB
testcase_15 AC 104 ms
55,792 KB
testcase_16 AC 103 ms
55,660 KB
testcase_17 AC 107 ms
56,052 KB
testcase_18 AC 103 ms
56,152 KB
testcase_19 AC 104 ms
55,940 KB
testcase_20 AC 102 ms
55,956 KB
testcase_21 AC 101 ms
55,924 KB
testcase_22 AC 101 ms
55,896 KB
testcase_23 AC 101 ms
56,072 KB
testcase_24 AC 102 ms
55,612 KB
testcase_25 AC 102 ms
55,704 KB
testcase_26 AC 110 ms
55,500 KB
testcase_27 AC 111 ms
55,836 KB
testcase_28 AC 103 ms
55,728 KB
testcase_29 AC 107 ms
56,160 KB
testcase_30 AC 102 ms
55,884 KB
testcase_31 AC 102 ms
54,440 KB
testcase_32 AC 103 ms
55,804 KB
testcase_33 AC 103 ms
56,108 KB
testcase_34 AC 111 ms
55,896 KB
権限があれば一括ダウンロードができます

ソースコード

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;
			if (n % 2 == 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);
				r2 *= 4;
				r2 %= mod;

				long ans = v1 - r2 + mod;
				ans %= mod;
				System.out.println(ans);
			} else {
				long x1 = x / 2;
				long x2 = x1 + 1;
				x1 %= mod;
				x2 %= mod;
				long v1 = x1 * x1 % mod;
				long v2 = x2 * x2 % mod;

				long r1 = n / 2;
				long r2 = r1 * r1 * 4;
				r2 %= mod;

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