結果
問題 | No.141 魔法少女コバ |
ユーザー |
|
提出日時 | 2019-01-26 05:44:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 1,449 ms |
コンパイル使用メモリ | 166,236 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-16 04:54:01 |
合計ジャッジ時間 | 3,982 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 93 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int m, n; cin >> m >> n; int g = __gcd(m, n); m /= g; n /= g; int ans = 0; while (true) { if (n == 1) { ans += m - 1; break; } if (m < n) { ans++; swap(m, n); continue; } ans += m / n; m %= n; } cout << ans << endl; return 0; }