結果

問題 No.237 作図可能性
ユーザー te-sh
提出日時 2017-05-24 17:20:59
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 450 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 101,084 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 19:22:17
合計ジャッジ時間 1,889 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bitmanip;  // BitArray

const long[] fermats = [3,5,17,257,65537];

void main()
{
  auto a = readln.chomp.to!long;

  auto count(long pf)
  {
    auto r = 0;
    for (; pf <= a; pf *= 2)
      if (pf >= 3) ++r;
    return r;
  }

  auto r = 0;
  foreach (i; 0..(1 << 5)) {
    auto pf = fermats.indexed(i.bitsSet).fold!"a * b"(1L);
    r += count(pf);
  }

  writeln(r);
}
0