結果

問題 No.1500 Super Knight
ユーザー ks2mks2m
提出日時 2021-05-07 22:04:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 3,918 ms
コンパイル使用メモリ 72,160 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2023-10-13 13:08:15
合計ジャッジ時間 8,802 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
55,736 KB
testcase_01 AC 103 ms
55,860 KB
testcase_02 AC 103 ms
56,224 KB
testcase_03 WA -
testcase_04 AC 103 ms
56,180 KB
testcase_05 AC 103 ms
55,964 KB
testcase_06 WA -
testcase_07 AC 103 ms
56,116 KB
testcase_08 AC 102 ms
55,596 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 103 ms
56,440 KB
testcase_13 AC 103 ms
56,180 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 103 ms
55,672 KB
testcase_17 WA -
testcase_18 AC 107 ms
55,896 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 103 ms
55,784 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 106 ms
56,144 KB
testcase_27 WA -
testcase_28 AC 110 ms
55,764 KB
testcase_29 WA -
testcase_30 AC 109 ms
55,720 KB
testcase_31 AC 101 ms
55,512 KB
testcase_32 AC 102 ms
55,808 KB
testcase_33 AC 103 ms
55,956 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
			}
			r2 *= 4;
			r2 %= mod;

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