結果

問題 No.420 mod2漸化式
ユーザー motimoti
提出日時 2016-09-09 23:26:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,630 bytes
コンパイル時間 1,453 ms
コンパイル使用メモリ 165,560 KB
実行使用メモリ 10,868 KB
最終ジャッジ日時 2023-08-25 23:23:08
合計ジャッジ時間 2,866 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,788 KB
testcase_01 AC 5 ms
10,732 KB
testcase_02 AC 5 ms
10,564 KB
testcase_03 AC 6 ms
10,568 KB
testcase_04 AC 5 ms
10,512 KB
testcase_05 AC 5 ms
10,588 KB
testcase_06 AC 5 ms
10,816 KB
testcase_07 AC 5 ms
10,692 KB
testcase_08 AC 5 ms
10,680 KB
testcase_09 AC 5 ms
10,672 KB
testcase_10 AC 5 ms
10,516 KB
testcase_11 AC 5 ms
10,512 KB
testcase_12 AC 5 ms
10,868 KB
testcase_13 AC 5 ms
10,732 KB
testcase_14 AC 5 ms
10,620 KB
testcase_15 AC 5 ms
10,692 KB
testcase_16 AC 6 ms
10,616 KB
testcase_17 AC 5 ms
10,584 KB
testcase_18 AC 5 ms
10,528 KB
testcase_19 AC 5 ms
10,568 KB
testcase_20 AC 5 ms
10,516 KB
testcase_21 AC 5 ms
10,664 KB
testcase_22 AC 6 ms
10,732 KB
testcase_23 AC 5 ms
10,524 KB
testcase_24 AC 5 ms
10,736 KB
testcase_25 AC 5 ms
10,532 KB
testcase_26 AC 5 ms
10,512 KB
testcase_27 AC 5 ms
10,520 KB
testcase_28 AC 5 ms
10,616 KB
testcase_29 AC 5 ms
10,764 KB
testcase_30 AC 6 ms
10,520 KB
testcase_31 AC 5 ms
10,676 KB
testcase_32 AC 5 ms
10,516 KB
testcase_33 AC 6 ms
10,516 KB
testcase_34 AC 5 ms
10,600 KB
testcase_35 AC 5 ms
10,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

constexpr int MOD = 1e9+7;

namespace math {

constexpr int MaxComb = 1010;

struct Combination {

  long long comb_[MaxComb][MaxComb];
    
  Combination() {
    rep(i, MaxComb) {
      comb_[i][0] = 1;
      REP(j, 1, i+1) {
        comb_[i][j] = comb_[i-1][j-1] + comb_[i-1][j];
        comb_[i][j] %= MOD;
      }
    }
  }

  long long comb(int n, int r) const { return comb_[n][r]; }

};

}

math::Combination cb;

int main() {
  ll ans[32] = {
    2147483647,
64424509410,
934155386445,
8718783606820,
58851789346035,
306029304599382,
1275122102497425,
4371847208562600,
12569060724617475,
30724370660176050,
64521178386369705,
117311233429763100,
185742786263791575,
257182319442172950,
312292816465495725,
333112337563195440,
  };

  for(int i=0; i<16; i++) {
    ans[30-i] = ans[i];
  }

//  rep(i, 32) cout << ans[i] << endl;

  // 31ビット中, 1が立つ組み合わせの数
  int x; cin >> x;
  if(x == 0) {
    cout << 1 << " " << 0 << endl;
  }
  else if(x > 31)
    cout << 0 << " " << 0 << endl;
  else {
    cout << cb.comb(31, x) << " " << ans[x-1] << endl;
  }

  return 0;
}
0