結果

問題 No.648  お や す み 
ユーザー GrenacheGrenache
提出日時 2018-02-09 22:42:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 6,319 ms
コンパイル使用メモリ 74,596 KB
実行使用メモリ 40,216 KB
最終ジャッジ日時 2023-10-11 22:07:43
合計ジャッジ時間 17,571 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
39,600 KB
testcase_01 AC 123 ms
39,212 KB
testcase_02 AC 124 ms
39,600 KB
testcase_03 AC 127 ms
39,584 KB
testcase_04 AC 123 ms
39,600 KB
testcase_05 AC 124 ms
39,496 KB
testcase_06 AC 125 ms
39,396 KB
testcase_07 AC 127 ms
39,424 KB
testcase_08 AC 124 ms
39,616 KB
testcase_09 AC 124 ms
39,612 KB
testcase_10 AC 124 ms
39,504 KB
testcase_11 AC 124 ms
39,516 KB
testcase_12 AC 124 ms
39,716 KB
testcase_13 AC 125 ms
39,216 KB
testcase_14 AC 127 ms
39,488 KB
testcase_15 AC 128 ms
39,572 KB
testcase_16 AC 125 ms
39,632 KB
testcase_17 AC 125 ms
39,636 KB
testcase_18 AC 127 ms
39,532 KB
testcase_19 AC 125 ms
39,548 KB
testcase_20 AC 124 ms
39,268 KB
testcase_21 AC 122 ms
39,212 KB
testcase_22 AC 125 ms
39,436 KB
testcase_23 AC 122 ms
39,652 KB
testcase_24 AC 125 ms
39,256 KB
testcase_25 AC 124 ms
39,512 KB
testcase_26 AC 124 ms
39,624 KB
testcase_27 AC 122 ms
39,748 KB
testcase_28 AC 124 ms
39,680 KB
testcase_29 AC 123 ms
39,456 KB
testcase_30 AC 122 ms
39,732 KB
testcase_31 AC 123 ms
39,576 KB
testcase_32 AC 125 ms
39,624 KB
testcase_33 AC 124 ms
39,260 KB
testcase_34 AC 122 ms
39,144 KB
testcase_35 AC 127 ms
39,288 KB
testcase_36 AC 124 ms
39,724 KB
testcase_37 AC 127 ms
39,408 KB
testcase_38 AC 127 ms
39,236 KB
testcase_39 AC 123 ms
39,572 KB
testcase_40 AC 122 ms
39,576 KB
testcase_41 AC 123 ms
39,844 KB
testcase_42 AC 123 ms
39,496 KB
testcase_43 AC 120 ms
39,740 KB
testcase_44 AC 120 ms
40,116 KB
testcase_45 AC 120 ms
39,468 KB
testcase_46 AC 122 ms
39,504 KB
testcase_47 AC 120 ms
39,524 KB
testcase_48 AC 121 ms
39,516 KB
testcase_49 AC 121 ms
39,592 KB
testcase_50 AC 123 ms
39,688 KB
testcase_51 AC 120 ms
39,560 KB
testcase_52 AC 121 ms
39,824 KB
testcase_53 AC 119 ms
39,276 KB
testcase_54 AC 124 ms
39,564 KB
testcase_55 AC 126 ms
40,216 KB
testcase_56 AC 126 ms
39,732 KB
testcase_57 AC 128 ms
40,036 KB
testcase_58 AC 121 ms
39,532 KB
testcase_59 AC 119 ms
39,248 KB
testcase_60 AC 123 ms
39,556 KB
testcase_61 AC 124 ms
39,300 KB
testcase_62 AC 125 ms
40,144 KB
testcase_63 AC 124 ms
39,412 KB
testcase_64 AC 125 ms
39,732 KB
testcase_65 AC 124 ms
39,444 KB
testcase_66 AC 123 ms
39,332 KB
testcase_67 AC 124 ms
39,476 KB
testcase_68 AC 122 ms
39,268 KB
testcase_69 AC 125 ms
39,216 KB
testcase_70 AC 125 ms
39,528 KB
testcase_71 AC 124 ms
39,320 KB
testcase_72 AC 125 ms
40,168 KB
testcase_73 AC 125 ms
39,236 KB
testcase_74 AC 126 ms
39,416 KB
testcase_75 AC 125 ms
39,952 KB
testcase_76 AC 125 ms
39,292 KB
testcase_77 AC 123 ms
39,572 KB
testcase_78 AC 126 ms
39,540 KB
testcase_79 AC 125 ms
39,244 KB
testcase_80 AC 124 ms
39,292 KB
testcase_81 AC 123 ms
39,428 KB
testcase_82 AC 125 ms
39,816 KB
testcase_83 AC 126 ms
40,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.math.*;
import java.util.*;


public class Main_yukicoder648 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();

		BigInteger d = BigInteger.ONE.add(BigInteger.valueOf(8).multiply(BigInteger.valueOf(n)));
		long l = 0;
		long r = 1_000_000_000_000_000_000L;
		while (r - l > 1) {
			long mid = l + (r - l) / 2;
			BigInteger x2 = BigInteger.valueOf(mid).multiply(BigInteger.valueOf(mid));
			if (x2.compareTo(d) >= 0) {
//			if (data[mid] > value) {
				r = mid;
			} else {
				l = mid;
			}
		}

		if (BigInteger.valueOf(r).multiply(BigInteger.valueOf(r)).compareTo(d) == 0) {
			pr.println("YES");
			pr.println((r - 1) / 2);
		} else {
			pr.println("NO");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0