結果
| 問題 | No.141 魔法少女コバ |
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-10-31 01:19:12 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 672 bytes |
| 記録 | |
| コンパイル時間 | 1,160 ms |
| コンパイル使用メモリ | 210,684 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-02 22:05:07 |
| 合計ジャッジ時間 | 4,006 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 93 |
ソースコード
#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;
int main(){
int m, n, ans = 0, t;
cin >> m >> n;
t = gcd(m, n);
m /= t;
n /= t;
if (n == 1) {
cout << m - 1 << endl;
return 0;
} else if (m > n) {
while (m > n){
m -= n;
ans++;
}
}
while (m != 1){
swap(m, n);
ans++;
while (m > n){
m -= n;
ans++;
}
}
cout << ans + n << endl;
}
kpinkcat