結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
Strorkis
|
| 提出日時 | 2020-10-02 22:42:38 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,107 bytes |
| コンパイル時間 | 14,405 ms |
| コンパイル使用メモリ | 381,088 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-17 22:27:03 |
| 合計ジャッジ時間 | 13,859 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#[allow(unused_macros)]
macro_rules! read_line_to_tuple {
( $( $t:ty ),* ) => {{
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let mut iter = input.split_whitespace();
( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
}};
}
#[allow(unused_macros)]
macro_rules! read_line_to_collection {
( $t:ty ) => {{
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
let iter = input.split_whitespace();
iter.map(|x| x.parse().unwrap()).collect::<$t>()
}};
}
fn solve() -> String {
let (mut a, b) = read_line_to_tuple!(i64, i64);
let mut ans = Vec::new();
let mut p = 1;
while a != b {
while a % (p << 1) == 0 && a + (p << 1) <= b { p <<= 1; }
while a + p > b { p >>= 1; }
a += p;
ans.push(p.to_string());
}
format!("{}\n{}", ans.len(), ans.join(" "))
}
fn main() {
let t = read_line_to_tuple!(usize);
let answers = (0..t).map(|_| solve()).collect::<Vec<_>>();
println!("{}", answers.join("\n"));
}
Strorkis