結果

問題 No.680 作れる数
ユーザー htensaihtensai
提出日時 2020-01-15 20:50:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 2,715 ms
コンパイル使用メモリ 71,448 KB
実行使用メモリ 56,388 KB
最終ジャッジ日時 2023-09-02 13:04:29
合計ジャッジ時間 18,379 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,228 KB
testcase_01 AC 123 ms
56,116 KB
testcase_02 AC 124 ms
55,912 KB
testcase_03 AC 122 ms
55,684 KB
testcase_04 AC 120 ms
55,536 KB
testcase_05 AC 122 ms
55,576 KB
testcase_06 AC 121 ms
56,120 KB
testcase_07 AC 126 ms
56,132 KB
testcase_08 AC 124 ms
56,112 KB
testcase_09 AC 331 ms
55,476 KB
testcase_10 WA -
testcase_11 AC 120 ms
55,320 KB
testcase_12 AC 1,672 ms
55,428 KB
testcase_13 AC 901 ms
55,576 KB
testcase_14 AC 1,477 ms
55,812 KB
testcase_15 AC 1,281 ms
55,760 KB
testcase_16 AC 1,137 ms
56,084 KB
testcase_17 AC 1,714 ms
55,696 KB
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        if (calc(0, 1)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
    
    static boolean calc(int s, int t) {
        s += t;
        if (s == n) {
            return true;
        } else if (s > n) {
            return false;
        }
        t *= 2;
        if (calc(s, t)) {
            return true;
        } else {
            return calc(s, t + 1);
        }
    }
    
}
0