結果

問題 No.420 mod2漸化式
ユーザー k
提出日時 2020-07-02 02:25:19
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 647 bytes
コンパイル時間 2,729 ms
コンパイル使用メモリ 192,048 KB
最終ジャッジ日時 2025-01-11 13:55:06
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int comb[32][32];

void init() {
  REP (i, 32) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; j++)
      comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  init();

  int x;
  cin >> x;

  if (x == 0)
    cout << 1 << " " << 0 << endl;
  else  if (x > 31)
    cout << 0 << " " << 0 << endl;
  else {
    int y = comb[31][x];
    long long z = 0;
    for (int i = 0; i < 31; i++)
      z += (1LL << i) * comb[30][x-1];
    cout << y << " " << z << endl;
  }
  
  return 0;
}
0