結果
| 問題 |
No.648 お や す み
|
| コンテスト | |
| ユーザー |
silviasetitech
|
| 提出日時 | 2020-03-15 16:19:39 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 2,000 ms |
| コード長 | 1,267 bytes |
| コンパイル時間 | 1,933 ms |
| コンパイル使用メモリ | 75,444 KB |
| 実行使用メモリ | 54,552 KB |
| 最終ジャッジ日時 | 2024-11-25 03:28:14 |
| 合計ジャッジ時間 | 14,853 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 84 |
ソースコード
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
*
* @author silviase
*/
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);
sheepSleep solver = new sheepSleep();
solver.solve(1, in, out);
out.close();
}
static class sheepSleep {
public void solve(int testNumber, Scanner in, PrintWriter out) {
long n = in.nextLong();
long ng = -1;
long ok = Integer.MAX_VALUE;
while (Math.abs(ok - ng) > 1) {
long mid = (ok + ng) / 2;
if (mid * (mid + 1) / 2 >= n) {
ok = mid;
} else {
ng = mid;
}
}
if (ok * (ok + 1) / 2 == n) {
out.println("YES");
out.println(ok);
} else {
out.println("NO");
}
}
}
}
silviasetitech