結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2018-04-19 11:01:16 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 104,920 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-13 00:41:16 |
合計ジャッジ時間 | 2,796 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}} void main() { ulong n; readV(n); auto d = nsqrt(n*8+1); if (d*d != n*8+1 || d%2 == 0) { writeln("NO"); return; } writeln("YES"); writeln((d-1)/2); } pure T nsqrt(T)(T n) { import std.algorithm, std.conv, std.range, core.bitop; if (n <= 1) return n; T m = T(1) << (n.bsr/2+1); return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T; }