結果
問題 | No.1794 Continued Fraction |
ユーザー |
![]() |
提出日時 | 2021-12-30 15:51:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 491 bytes |
コンパイル時間 | 2,012 ms |
コンパイル使用メモリ | 195,412 KB |
最終ジャッジ日時 | 2025-01-27 07:38:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 RE * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) typedef long long ll; #define int long long signed main(){ int n,m; cin>>n>>m; if(n%m==0){ cout<<n/m<<endl; return 0; } vector<int>ans; int amari=0; while(1){ ans.push_back(n/m); amari=n%m; if(amari==1){ ans.push_back(m); break; } n=m; m=amari; } rep(i,ans.size()){ if(i != 0) cout<<" "; cout<<ans[i]; } cout<<endl; return 0; }