結果
問題 | No.312 置換処理 |
ユーザー |
|
提出日時 | 2017-06-19 16:16:57 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 498 bytes |
コンパイル時間 | 902 ms |
コンパイル使用メモリ | 101,668 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 20:16:29 |
合計ジャッジ時間 | 2,700 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 45 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;void main(){auto n = readln.chomp.to!long;foreach (i; 3..n.nsqrt+1) {if (n % i == 0) {writeln(i);return;}}if (n % 2 == 0 && n > 4)writeln(n/2);elsewriteln(n);}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;}