結果
問題 | No.141 魔法少女コバ |
ユーザー |
![]() |
提出日時 | 2021-10-28 07:10:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 4,602 ms |
コンパイル使用メモリ | 249,816 KB |
最終ジャッジ日時 | 2025-01-25 07:59:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 93 |
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using mint = modint1000000007;using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf 1000000000000000000long long ans = 0LL;void Gcd(long long a,long long b){//cout<<ans<<','<<a<<','<<b<<endl;if(a==b){return;}if(a<b){ans++;swap(a,b);}if(a%b==0){ans += a/b - 1;return;}ans += (a - (a%b))/b;Gcd(a%b,b);}int main(){long long m,n;cin>>m>>n;long long g = gcd(m,n);m/=g;n/=g;Gcd(m,n);cout<<ans<<endl;return 0;}