結果

問題 No.1500 Super Knight
ユーザー ks2m
提出日時 2021-05-07 22:06:27
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 638 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 41,624 KB
最終ジャッジ日時 2024-09-15 10:01:57
合計ジャッジ時間 8,295 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 RE * 17
権限があれば一括ダウンロードができます

ソースコード

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