結果
| 問題 |
No.141 魔法少女コバ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-02 00:48:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 431 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 59,516 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 06:13:33 |
| 合計ジャッジ時間 | 2,687 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 93 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int main() {
int m, n;
cin >> m >> n;
int tmp = gcd(m, n);
m /= tmp;
n /= tmp;
int ans = m / n;
m %= n;
while(n != 1) {
if (m > n) {
m -= n;
} else {
swap(m, n);
}
ans++;
}
ans += m - 1;
cout << ans << endl;
return 0;
}