結果

問題 No.1794 Continued Fraction
ユーザー t98slider
提出日時 2023-04-19 21:44:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 1,665 ms
コンパイル使用メモリ 169,740 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 00:22:12
合計ジャッジ時間 2,876 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    vector<ll> ans;
    function<void(ll, ll)> rec = [&](ll A, ll B){
        if(A == 0 || B == 0) return;
        ans.emplace_back(A / B);
        rec(B, A % B);
    };
    rec(n, m);
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << (i + 1 == ans.size() ? '\n' : ' ');
    }
}
0