結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2016-09-09 23:26:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 1,630 bytes |
コンパイル時間 | 1,751 ms |
コンパイル使用メモリ | 166,540 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-12-24 11:17:40 |
合計ジャッジ時間 | 2,598 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#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;}