結果
問題 | No.141 魔法少女コバ |
ユーザー |
![]() |
提出日時 | 2018-05-27 21:56:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 465 bytes |
コンパイル時間 | 1,522 ms |
コンパイル使用メモリ | 165,724 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 07:22:21 |
合計ジャッジ時間 | 4,710 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 61 WA * 30 RE * 2 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main(){ | ^~~~
ソースコード
#include<bits/stdc++.h> typedef long long ll; using namespace std; int INF = 1LL << 30; int MOD = 1e9+7; ll gcd (ll a,ll b){ return b ? gcd(b,a%b) : a; } main(){ int M,N; cin >> M >> N; M /= gcd(M,N); N /= gcd(M,N); ll cnt = 0; while(N != 1){ if(M > N){ cnt += M / N; M -= (M / N) * N; }else{ swap(M,N); cnt++; } } cnt += M-1; cout << cnt << endl; }