結果
| 問題 |
No.141 魔法少女コバ
|
| コンテスト | |
| ユーザー |
IJMP320
|
| 提出日時 | 2015-02-01 23:55:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 844 bytes |
| コンパイル時間 | 516 ms |
| コンパイル使用メモリ | 53,376 KB |
| 実行使用メモリ | 817,136 KB |
| 最終ジャッジ日時 | 2024-06-23 05:40:06 |
| 合計ジャッジ時間 | 3,371 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 MLE * 1 -- * 91 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d %d",&N,&M);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
const int INF = 100000000;
int gcd( int m, int n )
{
if((0==m)||(0==n)) return 0;
while( m != n ) {
if (m>n) m = m - n;
else n = n - m;
}
return m;
}
struct K{
int n;
int m;
int deep;
K():n(0),m(0), deep(0){}
K(int n,int m, int deep) {
this->n = n;
this->m = m;
this->deep = deep;
}
};
int main(){
int N,M;
scanf("%d %d",&N,&M);
int ret = gcd(N,M);
N /= ret;
M /= ret;
queue<K> q;
q.push(K(1,1,0));
while(q.size()!=0) {
K k = q.front(); q.pop();
if(k.n == N && k.m == M) {
printf("%d\n",k.deep);
return 0;
}
K nk1=k, nk2=k;
nk1.n += k.m;
nk1.deep++;
nk2.n = k.m;
nk2.m = k.n;
nk2.deep++;
q.push(nk1);
q.push(nk2);
}
return 0;
}
IJMP320