結果
| 問題 |
No.141 魔法少女コバ
|
| コンテスト | |
| ユーザー |
HiroakiSoftware
|
| 提出日時 | 2015-02-02 00:02:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 507 bytes |
| コンパイル時間 | 327 ms |
| コンパイル使用メモリ | 22,528 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 05:43:58 |
| 合計ジャッジ時間 | 2,150 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 93 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf ( "%d %d" , &M , &N );
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main ( void ) {
int M , N;
int Count = 0;
int L;
bool bOK = true;
scanf ( "%d %d" , &M , &N );
while ( 1 ) {
if ( ( M == 0 ) || ( N == 0 ) ) {
bOK = false;
break;
}
if ( N == 1 ) {
Count += M - 1;
break;
}
L = M / N;
if ( M % N == 0 ) {
Count += L - 1;
break;
}
M -= N*L;
Count += L;
//交換(逆数)
L = M;
M = N;
N = L;
Count++;
}
if ( bOK ) printf ( "%d\n" , Count );
else printf ( "-1\n" );
return 0;
}
HiroakiSoftware