結果

問題 No.2655 Increasing Strides
ユーザー ks2mks2m
提出日時 2024-03-01 21:34:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 4,689 ms
コンパイル使用メモリ 76,588 KB
実行使用メモリ 58,084 KB
最終ジャッジ日時 2024-03-01 21:35:03
合計ジャッジ時間 10,872 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,576 KB
testcase_01 AC 128 ms
57,812 KB
testcase_02 AC 128 ms
56,112 KB
testcase_03 AC 130 ms
57,700 KB
testcase_04 AC 129 ms
57,824 KB
testcase_05 AC 139 ms
57,680 KB
testcase_06 AC 134 ms
57,816 KB
testcase_07 AC 128 ms
58,084 KB
testcase_08 AC 141 ms
57,608 KB
testcase_09 AC 117 ms
56,676 KB
testcase_10 AC 118 ms
56,668 KB
testcase_11 AC 129 ms
57,664 KB
testcase_12 AC 130 ms
57,828 KB
testcase_13 AC 139 ms
57,960 KB
testcase_14 AC 127 ms
57,840 KB
testcase_15 AC 127 ms
57,700 KB
testcase_16 AC 128 ms
57,680 KB
testcase_17 AC 129 ms
57,684 KB
testcase_18 AC 126 ms
55,892 KB
testcase_19 AC 131 ms
57,536 KB
testcase_20 AC 129 ms
57,712 KB
testcase_21 AC 126 ms
57,588 KB
testcase_22 AC 132 ms
57,816 KB
testcase_23 AC 131 ms
57,556 KB
testcase_24 AC 139 ms
57,812 KB
testcase_25 AC 131 ms
57,664 KB
testcase_26 AC 135 ms
57,744 KB
testcase_27 AC 137 ms
57,716 KB
testcase_28 AC 130 ms
57,708 KB
testcase_29 AC 140 ms
57,828 KB
testcase_30 AC 148 ms
57,680 KB
testcase_31 AC 142 ms
57,820 KB
testcase_32 AC 131 ms
57,816 KB
testcase_33 AC 131 ms
57,848 KB
testcase_34 AC 137 ms
57,944 KB
testcase_35 AC 138 ms
57,720 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();

		long s0 = 0;
		long s1 = 0;
		for (int i = 2; i <= n; i += 2) {
			s0 += i;
		}
		for (int i = 1; i <= n; i += 2) {
			s1 += i;
		}
		if (s0 % 2 != 0 || s1 % 2 != 0) {
			System.out.println("No");
			return;
		}
		s0 /= 2;
		s1 /= 2;

		int start = n;
		if (n % 2 == 1) {
			start--;
		}
		for (int i = start; i > 0; i -= 2) {
			if (i <= s0) {
				s0 -= i;
			}
		}

		start = n;
		if (n % 2 == 0) {
			start--;
		}
		for (int i = start; i > 0; i -= 2) {
			if (i <= s1) {
				s1 -= i;
			}
		}

		if (s0 == 0 && s1 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}
0