結果
問題 |
No.141 魔法少女コバ
|
ユーザー |
|
提出日時 | 2016-09-13 16:12:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 532 bytes |
コンパイル時間 | 717 ms |
コンパイル使用メモリ | 66,796 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-17 04:53:53 |
合計ジャッジ時間 | 2,705 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 93 |
ソースコード
#include <iostream> #include <math.h> int func(int a,int b){ while(1){ int r=a%b; if(r==0)return b; a=b; b=r; } } int main(){ int a,b; std::cin>>a>>b; if(a==b){ std::cout<<0<<std::endl; return 0; } int m=func(a,b); a/=m; b/=m; int count=0; while(1){ if(a>b){ int s=a/b; a-=s*b; count+=s; }else{ int tmp=a; a=b; b=tmp; count++; } if(a==1){ count+=b; break; } if(b==1){ count+=a-1; break; } if(a==b){ break; } } std::cout<<count<<std::endl; return 0; }