結果

問題 No.683 Two Operations No.3
ユーザー Hdz06052373Hdz06052373
提出日時 2018-05-17 22:39:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 578 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 51,328 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-10 22:41:55
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool search(int, int)’:
main.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <iostream>

using namespace std;

bool search(int a, int b) ;

int main() {
    int a, b;
    
    cin >> a >> b;
    
    if(search(a, b))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

bool search(int a, int b) {
    if((a == 0) || (b == 0))
        return true;
    else if((a%2 != 0) && (b%2 != 0))
        return false;
    else if((a%2 == 0) && (b%2 == 0))
        return search(a/2, b-1) || search(a-1, b/2);
    else if(a%2 != 0)
        return search(a-1, b/2);
    else if(b%2 != 0)
        return search(a/2, b-1);
}
0