結果

問題 No.648  お や す み 
ユーザー tentententen
提出日時 2023-08-01 10:12:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,908 bytes
コンパイル時間 2,869 ms
コンパイル使用メモリ 94,380 KB
実行使用メモリ 37,180 KB
最終ジャッジ日時 2024-04-19 09:44:46
合計ジャッジ時間 9,307 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 52 ms
36,988 KB
testcase_02 WA -
testcase_03 AC 52 ms
36,992 KB
testcase_04 AC 51 ms
36,864 KB
testcase_05 WA -
testcase_06 AC 52 ms
36,960 KB
testcase_07 AC 52 ms
36,876 KB
testcase_08 AC 52 ms
37,180 KB
testcase_09 WA -
testcase_10 AC 51 ms
37,052 KB
testcase_11 AC 52 ms
36,668 KB
testcase_12 AC 51 ms
36,752 KB
testcase_13 AC 52 ms
37,012 KB
testcase_14 AC 52 ms
36,816 KB
testcase_15 AC 52 ms
37,004 KB
testcase_16 AC 51 ms
36,920 KB
testcase_17 AC 51 ms
36,804 KB
testcase_18 AC 50 ms
36,944 KB
testcase_19 AC 50 ms
37,048 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 52 ms
36,768 KB
testcase_31 AC 52 ms
36,860 KB
testcase_32 AC 51 ms
37,000 KB
testcase_33 AC 51 ms
37,144 KB
testcase_34 AC 52 ms
36,988 KB
testcase_35 AC 52 ms
37,044 KB
testcase_36 AC 51 ms
36,848 KB
testcase_37 AC 51 ms
36,820 KB
testcase_38 AC 52 ms
36,988 KB
testcase_39 AC 53 ms
36,896 KB
testcase_40 AC 53 ms
36,604 KB
testcase_41 AC 51 ms
36,900 KB
testcase_42 AC 53 ms
36,916 KB
testcase_43 AC 52 ms
36,572 KB
testcase_44 AC 49 ms
36,816 KB
testcase_45 AC 51 ms
36,768 KB
testcase_46 AC 52 ms
36,988 KB
testcase_47 AC 48 ms
36,768 KB
testcase_48 AC 52 ms
36,692 KB
testcase_49 AC 52 ms
36,516 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 51 ms
36,756 KB
testcase_61 AC 52 ms
37,016 KB
testcase_62 AC 53 ms
36,884 KB
testcase_63 AC 53 ms
36,900 KB
testcase_64 AC 53 ms
36,992 KB
testcase_65 AC 52 ms
36,964 KB
testcase_66 AC 53 ms
36,892 KB
testcase_67 AC 52 ms
36,944 KB
testcase_68 AC 52 ms
36,888 KB
testcase_69 AC 51 ms
36,912 KB
testcase_70 AC 49 ms
37,024 KB
testcase_71 AC 52 ms
36,888 KB
testcase_72 AC 51 ms
36,924 KB
testcase_73 AC 54 ms
36,812 KB
testcase_74 AC 52 ms
37,020 KB
testcase_75 AC 52 ms
37,012 KB
testcase_76 AC 51 ms
36,892 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        long left = 0;
        long right = Integer.MAX_VALUE;
        while (right - left > 1) {
            long m = (left + right) / 2;
            if (m * (m + 1) / 2 <= n) {
                left = m;
            } else {
                right = m;
            }
        }
        if (left * (left + 1) / 2 == n) {
            System.out.println("Yes");
            System.out.println(left);
        } else {
            System.out.println("NO");
        }
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0