結果
問題 |
No.3254 Xor, Max and Sum
|
ユーザー |
![]() |
提出日時 | 2025-09-05 22:58:25 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 610 bytes |
コンパイル時間 | 5,899 ms |
コンパイル使用メモリ | 76,820 KB |
実行使用メモリ | 46,612 KB |
最終ジャッジ日時 | 2025-09-05 22:58:40 |
合計ジャッジ時間 | 11,445 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 2 |
other | AC * 16 RE * 32 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long n = sc.nextInt(); long m = sc.nextInt(); sc.close(); if (n == 1) { System.out.println(0); } else if (n % 2 == 0) { System.out.println(n * m); } else { long v1 = (n - 3) * m; long v2 = 0; int cnt = 0; for (int i = 30; i >= 0; i--) { if ((m >> i & 1) == 1) { cnt++; v2 += 1L << i; } else if (cnt >= 2) { v2 += 1L << i; } } System.out.println(v1 + v2 * 2); throw new RuntimeException(); } } }