結果

問題 No.648  お や す み 
ユーザー denderaKawazudenderaKawazu
提出日時 2018-02-09 23:47:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,370 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 77,224 KB
実行使用メモリ 41,800 KB
最終ジャッジ日時 2024-04-17 10:05:17
合計ジャッジ時間 15,250 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 132 ms
41,596 KB
testcase_02 AC 133 ms
41,280 KB
testcase_03 AC 131 ms
41,164 KB
testcase_04 AC 131 ms
41,468 KB
testcase_05 AC 134 ms
41,408 KB
testcase_06 AC 120 ms
40,080 KB
testcase_07 AC 133 ms
41,672 KB
testcase_08 AC 134 ms
41,508 KB
testcase_09 AC 132 ms
41,736 KB
testcase_10 AC 132 ms
41,508 KB
testcase_11 AC 133 ms
41,756 KB
testcase_12 AC 123 ms
40,284 KB
testcase_13 AC 131 ms
41,140 KB
testcase_14 AC 132 ms
41,540 KB
testcase_15 AC 132 ms
41,724 KB
testcase_16 AC 131 ms
41,612 KB
testcase_17 AC 136 ms
41,456 KB
testcase_18 AC 135 ms
41,596 KB
testcase_19 AC 131 ms
41,152 KB
testcase_20 AC 134 ms
41,800 KB
testcase_21 AC 122 ms
40,388 KB
testcase_22 AC 131 ms
41,160 KB
testcase_23 AC 132 ms
41,432 KB
testcase_24 AC 133 ms
41,516 KB
testcase_25 AC 132 ms
41,208 KB
testcase_26 AC 131 ms
41,380 KB
testcase_27 AC 118 ms
40,440 KB
testcase_28 AC 133 ms
41,644 KB
testcase_29 AC 133 ms
41,724 KB
testcase_30 AC 117 ms
40,344 KB
testcase_31 AC 117 ms
40,104 KB
testcase_32 AC 132 ms
41,420 KB
testcase_33 AC 134 ms
41,556 KB
testcase_34 AC 133 ms
41,424 KB
testcase_35 AC 130 ms
41,556 KB
testcase_36 AC 131 ms
41,536 KB
testcase_37 AC 129 ms
41,472 KB
testcase_38 AC 116 ms
40,340 KB
testcase_39 AC 129 ms
41,492 KB
testcase_40 AC 133 ms
41,592 KB
testcase_41 AC 134 ms
41,448 KB
testcase_42 AC 133 ms
41,428 KB
testcase_43 AC 134 ms
41,472 KB
testcase_44 AC 134 ms
41,768 KB
testcase_45 AC 133 ms
41,800 KB
testcase_46 AC 129 ms
41,256 KB
testcase_47 AC 120 ms
40,352 KB
testcase_48 AC 132 ms
41,464 KB
testcase_49 AC 131 ms
41,604 KB
testcase_50 AC 134 ms
41,556 KB
testcase_51 AC 134 ms
41,456 KB
testcase_52 AC 134 ms
41,100 KB
testcase_53 AC 121 ms
40,284 KB
testcase_54 AC 130 ms
41,316 KB
testcase_55 AC 133 ms
41,268 KB
testcase_56 AC 134 ms
41,704 KB
testcase_57 AC 134 ms
41,668 KB
testcase_58 AC 131 ms
41,632 KB
testcase_59 AC 133 ms
41,176 KB
testcase_60 AC 134 ms
41,540 KB
testcase_61 AC 135 ms
41,288 KB
testcase_62 AC 118 ms
40,368 KB
testcase_63 AC 135 ms
41,140 KB
testcase_64 AC 134 ms
41,424 KB
testcase_65 AC 131 ms
41,440 KB
testcase_66 AC 134 ms
41,348 KB
testcase_67 AC 131 ms
41,176 KB
testcase_68 AC 131 ms
41,160 KB
testcase_69 AC 130 ms
41,416 KB
testcase_70 AC 132 ms
41,724 KB
testcase_71 AC 134 ms
41,472 KB
testcase_72 AC 133 ms
41,464 KB
testcase_73 AC 133 ms
41,296 KB
testcase_74 AC 131 ms
41,256 KB
testcase_75 AC 134 ms
41,724 KB
testcase_76 AC 123 ms
40,300 KB
testcase_77 AC 134 ms
41,672 KB
testcase_78 AC 134 ms
41,296 KB
testcase_79 AC 133 ms
41,584 KB
testcase_80 AC 134 ms
41,468 KB
testcase_81 AC 135 ms
41,484 KB
testcase_82 AC 129 ms
41,468 KB
testcase_83 AC 132 ms
41,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            long maxN = n;
            long minN = 0;
            long cn = -1;

            while ((maxN + minN) / 2 != cn) {
                cn = (maxN + minN) / 2;
                double sum = (double) cn * ((double) cn + 1) / 2;
                if (sum == n) {
                    break;
                } else if (sum > n) {
                    maxN = cn;
                } else if (sum < n) {
                    minN = cn;
                }
            }

            if (cn * (cn + 1) / 2 == n) {
                out.println("YES");
                out.println(cn);
            } else {
                out.println("NO");
            }
        }

    }
}

0