結果

問題 No.589 Counting Even
ユーザー dptbldptbl
提出日時 2017-11-03 23:48:12
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 1,008 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 103,604 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-06-12 22:19:22
合計ジャッジ時間 4,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 24 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long g(long n, long r)
{
  long v = 1;
  foreach (i; 0 .. n)
  {
    v *= i + 1;
  }
  foreach (i; 0 .. r)
  {
    v /= i + 1;
  }
  foreach (i; 0 .. (n - r))
  {
    v /= i + 1;
  }
  return v;
}

long f(long n)
{
  long cnt = 0;
  foreach (i; 1 .. n)
  {
    long v = g(n, i);
    if (v % 2 == 0)
    {
      ++cnt;
    }
  }
  return cnt;
}

int a(long n)
{
  int cnt = 0;
  long two = 2;
  while (two <= n)
  {
    cnt += n / two;
    two <<= 1L;
  }
  return cnt;
}

void main()
{
  long n = readln.chomp.to!long;
  // stderr.writeln = n.f;
  int cnt = n.a;
  int ans = 1;
  for (long ite = n / 2; 0 <= ite; --ite)
  {
    int cnt2 = ite.a;
    int cnt3 = (n - ite).a;
    if (cnt2 + cnt3 < cnt) {
      break;
    }
    ++ans;
  }
  (n - ans).writeln;
}
0