結果

問題 No.680 作れる数
ユーザー htensai
提出日時 2020-01-15 20:49:40
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 624 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 74,316 KB
実行使用メモリ 56,348 KB
最終ジャッジ日時 2024-06-11 19:43:34
合計ジャッジ時間 17,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 19 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

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