結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2018-04-19 10:59:21 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 664 ms |
コンパイル使用メモリ | 104,868 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-13 00:41:13 |
合計ジャッジ時間 | 2,485 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 79 WA * 5 |
ソースコード
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 = 1 << (n.bsr/2+1); return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T; }