結果
問題 | No.2655 Increasing Strides |
ユーザー |
![]() |
提出日時 | 2024-03-01 21:34:52 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 2,360 ms |
コンパイル使用メモリ | 77,236 KB |
実行使用メモリ | 54,324 KB |
最終ジャッジ日時 | 2024-09-29 13:35:25 |
合計ジャッジ時間 | 7,523 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
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"); } } }