結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
![]() |
提出日時 | 2025-09-19 21:54:05 |
言語 | Rust (1.83.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 618 bytes |
コンパイル時間 | 12,513 ms |
コンパイル使用メモリ | 402,332 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-19 21:54:21 |
合計ジャッジ時間 | 15,100 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 RE * 3 |
ソースコード
use proconio::input; use std::io::Write; fn main() { input! { t: usize } let mut output = std::io::BufWriter::new(std::io::stdout().lock()); for _ in 0..t { let ans = solve(); writeln!(output, "{}", ans.unwrap_or(!0) as isize).unwrap(); } } fn solve() -> Option<usize> { input! { n: usize } if n.count_ones() == 1 { None } else { let mask = (0..30) .map(|i| (1 << i) - 1) .find(|&mask| (n & mask).count_ones() > 1) .unwrap(); let ans = mask + 1 - (n & mask); Some(ans) } } // 10101101 => 10110000