結果

問題 No.420 mod2漸化式
ユーザー algon_320algon_320
提出日時 2016-09-10 00:43:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,424 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 165,900 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 11:24:43
合計ジャッジ時間 3,025 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

//-------- 組み合わせ: nCr → combination[n][r]
const int N_MAX = 32;
ll combination[N_MAX][N_MAX];
void combination_init() {
    for(int i=0; i<N_MAX; i++) combination[i][0] = 1;
    for(int i=1; i<N_MAX; i++) {
        for(int j=1; j<N_MAX; j++) {
            combination[i][j] = combination[i-1][j] + combination[i-1][j-1];
        }
    }
}

signed main() {
    ll x;
    cin>>x;
    if(x==0) {
        cout<<"1 0"<<endl;
        return 0;
    }
    if(x>31) {
        cout<<"0 0"<<endl;
        return 0;
    }

    combination_init();
    cout<<combination[31][x]<<" "<<2147483647*combination[30][x-1]<<endl;
    return 0;
}
0