結果
問題 | No.1895 Mod 2 |
ユーザー |
|
提出日時 | 2024-10-04 21:19:00 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 713 bytes |
コンパイル時間 | 12,385 ms |
コンパイル使用メモリ | 401,580 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 21:19:14 |
合計ジャッジ時間 | 12,430 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
ソースコード
use proconio::input;fn main() {input! {t:usize,}for _ in 0..t {input! {l:usize,r:usize,}let ans = (2 + f(r) % 2 - f(l - 1) % 2) % 2;println!("{}", ans);}}const NG: usize = 100000000;fn f(m: usize) -> usize {let is_ok0 = |x| x * x <= m;let is_ok1 = |x| x * x * 2 <= m;(nibutan(0, NG, is_ok0) % 2 + nibutan(0, NG, is_ok1) % 2) % 2}fn nibutan<F>(mut ok: usize, mut ng: usize, is_ok: F) -> usizewhereF: Fn(usize) -> bool,{while ng - ok > 1 {let mid = (ok + ng) / 2;if is_ok(mid) {ok = mid;} else {ng = mid;}}ok}