結果
問題 | No.648 お や す み |
ユーザー | denderaKawazu |
提出日時 | 2018-02-09 23:49:05 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 1,503 bytes |
コンパイル時間 | 2,070 ms |
コンパイル使用メモリ | 76,996 KB |
実行使用メモリ | 42,060 KB |
最終ジャッジ日時 | 2024-09-13 21:05:15 |
合計ジャッジ時間 | 15,415 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
41,188 KB |
testcase_01 | AC | 134 ms
41,404 KB |
testcase_02 | AC | 122 ms
40,084 KB |
testcase_03 | AC | 133 ms
41,328 KB |
testcase_04 | AC | 136 ms
41,464 KB |
testcase_05 | AC | 119 ms
41,348 KB |
testcase_06 | AC | 122 ms
40,368 KB |
testcase_07 | AC | 135 ms
41,612 KB |
testcase_08 | AC | 133 ms
41,268 KB |
testcase_09 | AC | 135 ms
41,572 KB |
testcase_10 | AC | 120 ms
41,408 KB |
testcase_11 | AC | 120 ms
40,408 KB |
testcase_12 | AC | 133 ms
41,272 KB |
testcase_13 | AC | 131 ms
41,516 KB |
testcase_14 | AC | 133 ms
41,500 KB |
testcase_15 | AC | 134 ms
41,180 KB |
testcase_16 | AC | 134 ms
41,628 KB |
testcase_17 | AC | 121 ms
40,288 KB |
testcase_18 | AC | 134 ms
41,312 KB |
testcase_19 | AC | 135 ms
41,396 KB |
testcase_20 | AC | 133 ms
41,408 KB |
testcase_21 | AC | 133 ms
41,544 KB |
testcase_22 | AC | 120 ms
40,428 KB |
testcase_23 | AC | 135 ms
41,568 KB |
testcase_24 | AC | 136 ms
41,588 KB |
testcase_25 | AC | 135 ms
41,668 KB |
testcase_26 | AC | 122 ms
40,516 KB |
testcase_27 | AC | 134 ms
41,292 KB |
testcase_28 | AC | 133 ms
41,496 KB |
testcase_29 | AC | 134 ms
41,440 KB |
testcase_30 | AC | 136 ms
41,580 KB |
testcase_31 | AC | 121 ms
40,388 KB |
testcase_32 | AC | 136 ms
42,060 KB |
testcase_33 | AC | 130 ms
41,276 KB |
testcase_34 | AC | 132 ms
41,408 KB |
testcase_35 | AC | 132 ms
41,468 KB |
testcase_36 | AC | 130 ms
41,304 KB |
testcase_37 | AC | 136 ms
41,556 KB |
testcase_38 | AC | 133 ms
41,644 KB |
testcase_39 | AC | 136 ms
41,612 KB |
testcase_40 | AC | 130 ms
41,448 KB |
testcase_41 | AC | 130 ms
41,700 KB |
testcase_42 | AC | 137 ms
41,588 KB |
testcase_43 | AC | 135 ms
41,320 KB |
testcase_44 | AC | 133 ms
41,308 KB |
testcase_45 | AC | 133 ms
41,740 KB |
testcase_46 | AC | 135 ms
41,644 KB |
testcase_47 | AC | 135 ms
41,344 KB |
testcase_48 | AC | 133 ms
41,532 KB |
testcase_49 | AC | 130 ms
41,688 KB |
testcase_50 | AC | 121 ms
41,540 KB |
testcase_51 | AC | 136 ms
41,596 KB |
testcase_52 | AC | 135 ms
41,504 KB |
testcase_53 | AC | 135 ms
41,564 KB |
testcase_54 | AC | 135 ms
41,444 KB |
testcase_55 | AC | 134 ms
41,620 KB |
testcase_56 | AC | 131 ms
41,820 KB |
testcase_57 | AC | 132 ms
41,848 KB |
testcase_58 | AC | 133 ms
41,520 KB |
testcase_59 | AC | 134 ms
41,412 KB |
testcase_60 | AC | 118 ms
41,856 KB |
testcase_61 | AC | 132 ms
41,528 KB |
testcase_62 | AC | 132 ms
41,540 KB |
testcase_63 | AC | 132 ms
41,576 KB |
testcase_64 | AC | 133 ms
41,440 KB |
testcase_65 | AC | 135 ms
41,264 KB |
testcase_66 | AC | 121 ms
40,228 KB |
testcase_67 | AC | 133 ms
41,808 KB |
testcase_68 | AC | 135 ms
41,284 KB |
testcase_69 | AC | 133 ms
41,492 KB |
testcase_70 | AC | 135 ms
41,664 KB |
testcase_71 | AC | 132 ms
41,836 KB |
testcase_72 | AC | 134 ms
41,680 KB |
testcase_73 | AC | 133 ms
41,688 KB |
testcase_74 | AC | 133 ms
41,296 KB |
testcase_75 | AC | 133 ms
41,672 KB |
testcase_76 | AC | 133 ms
41,608 KB |
testcase_77 | AC | 132 ms
41,676 KB |
testcase_78 | AC | 133 ms
41,500 KB |
testcase_79 | AC | 133 ms
41,720 KB |
testcase_80 | AC | 132 ms
41,548 KB |
testcase_81 | AC | 135 ms
41,344 KB |
testcase_82 | AC | 140 ms
41,644 KB |
testcase_83 | AC | 139 ms
41,332 KB |
ソースコード
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; if (n == 1) { out.println("YES"); out.println(1); return; } 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"); } } } }