結果
問題 | No.648 お や す み |
ユーザー |
|
提出日時 | 2024-09-20 21:50:02 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 509 bytes |
コンパイル時間 | 5,247 ms |
コンパイル使用メモリ | 170,240 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 21:50:10 |
合計ジャッジ時間 | 4,755 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
ソースコード
import std;import std.string;ulong sqrtUlong(ulong n) {if (0 == n || 1 == n) {return n;}else {ulong x0 = n / 2;ulong x1 = (x0 + n / x0) / 2;while (x1 < x0) {x0 = x1;x1 = (x0 + n / x0) / 2;}return x0;}}void main() {ulong n = 2 * readln.chomp.to!ulong;ulong k = sqrtUlong(n);if (n == k * (k + 1)) {writeln("YES");writeln(k);}else {writeln("NO");}}