結果

問題 No.141 魔法少女コバ
ユーザー yuppe19 😺
提出日時 2015-04-25 22:09:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 435 bytes
コンパイル時間 1,192 ms
コンパイル使用メモリ 159,000 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 02:39:04
合計ジャッジ時間 4,120 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 93
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     int m, n;   scanf("%d%d", &m, &n);
      |                 ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int m, n;   scanf("%d%d", &m, &n);
    int g = __gcd(m, n);
    m /= g, n /= g;
    int res = 0;
    for( ; ; ) {
        if(m < n) {
            swap(m, n);
            res += 1;
        }
        int d = m / n;
        int r = m % n;
        res += d - 1;
        if(r == 0) { break; }
        m = r;
        res += 1;
    }
    printf("%d\n", res);
    return 0;
}
0