結果

問題 No.1500 Super Knight
ユーザー ks2m
提出日時 2021-05-07 22:04:30
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 3,212 ms
コンパイル使用メモリ 74,024 KB
実行使用メモリ 41,656 KB
最終ジャッジ日時 2024-09-15 09:58:06
合計ジャッジ時間 9,148 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 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;
			}
			r2 *= 4;
			r2 %= mod;

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