結果

問題 No.141 魔法少女コバ
ユーザー kk
提出日時 2020-07-03 03:36:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 1,812 ms
コンパイル使用メモリ 191,972 KB
最終ジャッジ日時 2025-01-11 14:00:25
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 93
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

long long solve(int m, int n) {
  if (m == n) return 0;
  if (n > m) return 1+solve(n, m);
  if (m % n == 0) return m/n-1;
  return m/n+solve(m%n, n);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m, n;
  cin >> m >> n;
  cout << solve(m, n) << endl;
  
  return 0;
}
0