結果
| 問題 |
No.1794 Continued Fraction
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-07 04:06:42 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,211 bytes |
| コンパイル時間 | 11,575 ms |
| コンパイル使用メモリ | 401,804 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-11 16:55:42 |
| 合計ジャッジ時間 | 14,558 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 RE * 11 |
ソースコード
#[macro_export]
macro_rules! setup {
{ mut $input:ident: SplitWhitespace $(,)? } => {
use std::io::Read;
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).ok();
let mut $input = buf.split_whitespace();
};
}
#[macro_export]
macro_rules! parse_next {
($str_iter:expr) => {
$str_iter.next().unwrap().parse().ok().unwrap()
};
}
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
fn main() {
setup! { mut input: SplitWhitespace };
let n: usize = parse_next!(input);
let m: usize = parse_next!(input);
let ans = (|| {
let mut a = vec![];
let mut top = n;
let mut bottom = m;
loop {
if bottom == 1 {
a.push(top);
break;
}
let quotient = top / bottom;
a.push(quotient);
{
let next_top = bottom;
let next_bottom = top - bottom * quotient;
top = next_top;
bottom = next_bottom;
}
}
a.iter().map(usize::to_string).collect::<Vec<_>>().join(" ")
})();
println!("{}", ans);
}