結果

問題 No.141 魔法少女コバ
ユーザー peroonperoon
提出日時 2019-04-05 20:49:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,253 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 93,512 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-04 04:48:34
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 RE -
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 2 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 RE -
testcase_39 AC 2 ms
4,376 KB
testcase_40 WA -
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 1 ms
4,376 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 2 ms
4,380 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 2 ms
4,376 KB
testcase_53 WA -
testcase_54 AC 2 ms
4,376 KB
testcase_55 WA -
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 2 ms
4,380 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 AC 2 ms
4,380 KB
testcase_67 WA -
testcase_68 AC 1 ms
4,380 KB
testcase_69 AC 2 ms
4,380 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 1 ms
4,376 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 WA -
testcase_74 AC 2 ms
4,380 KB
testcase_75 AC 2 ms
4,380 KB
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 2 ms
4,380 KB
testcase_79 WA -
testcase_80 AC 1 ms
4,376 KB
testcase_81 AC 1 ms
4,376 KB
testcase_82 AC 1 ms
4,380 KB
testcase-evil-0.txt AC 1 ms
4,376 KB
testcase-evil-1.txt WA -
testcase-evil-2.txt WA -
testcase-evil-3.txt WA -
testcase-evil-4.txt WA -
testcase-evil-5.txt AC 2 ms
4,376 KB
testcase-evil-6.txt AC 2 ms
4,376 KB
testcase-evil-7.txt WA -
testcase-evil-8.txt AC 2 ms
4,380 KB
testcase-evil-9.txt AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll M, N;
    cin >> M >> N;

    if(M==N){
        p(0);
        return 0;
    }

    if(M%N==0){
        p(M/N);
        return 0;
    }

    // 通分
    M /= gcd(M, N);
    N /= gcd(M, N);

    ll num = 0;
    while(M!=1){
        if(M>N){
            num += M/N;
            M %= N;
            continue;
        }

        if(M<N){
            num++;
            swap(M, N);
        }
    }

    num++;
    num+=N-1;
    
    p(num);
    
    return 0;
}
0