結果

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

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> V;
typedef vector<V> VV;
void rec(int v,int cnt,VV& f,VV &sum){
if(v<cnt){
f[v][cnt]=0;
return;
}
if(f[v][cnt]>=0)return;
if(cnt==0){
rec(v-1,cnt,f,sum);
f[v][cnt]=f[v-1][cnt];
sum[v][cnt]=sum[v-1][cnt];
return;
}
rec(v-1,cnt-1,f,sum);
rec(v-1,cnt,f,sum);
f[v][cnt]=f[v-1][cnt-1]+f[v-1][cnt];
sum[v][cnt]=sum[v-1][cnt]+sum[v-1][cnt-1]+f[v-1][cnt-1]*(1ll<<(v-1));
}
int main(){
VV f(40,V(40,-1)),sum(40,V(40,0));
f[1][1]=1;f[1][0]=1;sum[1][1]=1;f[0][0]=0;
int x;
cin>>x;
if(x>31){cout<<"0 0"<<endl;}
else{
rec(31,x,f,sum);
cout<<f[31][x]<<" "<<sum[31][x]<<endl;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0