結果
問題 | No.141 魔法少女コバ |
ユーザー |
|
提出日時 | 2016-11-29 12:40:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 424 bytes |
コンパイル時間 | 1,570 ms |
コンパイル使用メモリ | 165,428 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 13:26:21 |
合計ジャッジ時間 | 3,704 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 93 |
ソースコード
#include <bits/stdc++.h>using namespace std;void gcd( int x, int y, int &cnt ){if( x == 1 and y == 1 )return;if( not ( x >= y ) )++cnt, swap( x, y );if( y == 1 )return ( void ) ( cnt += x - 1 );cnt += x / y;gcd( x % y, y, cnt );}signed main(){int M, N; cin >> M >> N;int g = __gcd( M, N );M /= g, N /= g;int ans = 0;gcd( M, N, ans );cout << ans << endl;return 0;}