結果

問題 No.680 作れる数
ユーザー Hdz06052373Hdz06052373
提出日時 2018-05-17 10:17:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 52,580 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-10 22:29:09
合計ジャッジ時間 4,493 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,384 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

string generate(int n);

int main() {
    int n;
    cin >> n;
    cout << generate(n) << endl;
    return 0;
}

string generate(int n) {
    int s1 = 0, t1 = 0;
    do {
        for(int coin = 0; coin <= 1; coin++) {
            int s2 = s1, t2 = t1;
            //1は表
            t2 *= 2;
            if(coin == 1)
                t2++;
            s2 += t2;
            if((coin == 1) || (s2 == n)) {
                s1 = s2;
                t1 = t2;
                break;
            }
        }
    } while((s1 == n) || (s1 > n));

    if(s1 == n)
        return "YES";
    else
        return "NO";
}
0