結果
| 問題 |
No.1794 Continued Fraction
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-07 04:13:05 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,182 bytes |
| コンパイル時間 | 10,566 ms |
| コンパイル使用メモリ | 402,516 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-11 17:01:54 |
| 合計ジャッジ時間 | 12,231 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#[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 {
let quotient = top / bottom;
a.push(quotient);
{
let next_top = bottom;
let next_bottom = top - bottom * quotient;
top = next_top;
bottom = next_bottom;
}
if bottom == 0 {
break;
}
}
a.iter().map(usize::to_string).collect::<Vec<_>>().join(" ")
})();
println!("{}", ans);
}