結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2016-09-09 22:46:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,166 bytes |
コンパイル時間 | 721 ms |
コンパイル使用メモリ | 84,856 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 11:03:17 |
合計ジャッジ時間 | 1,889 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <iomanip> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(int i = 0;i < n;++i) #define LONGINF 1000000000000000000 long long dp[1000][1000] = {}; long long wa[1000][1000] = {}; int main() { long long x; cin >> x; dp[0][0] = 1; if (x > 40) { cout << "0 0" << endl; return 0; } long long cnt = 1; for (int i = 1;i <= 31;++i) { for (int q = 0;q <= 50;++q) { dp[i][q] += dp[i - 1][q]; if (wa[i][q] != -1) { wa[i][q] += wa[i - 1][q]; } else { if (wa[i - 1][q] != -1) { wa[i][q] = wa[i - 1][q]; } } } for (int q = 1;q <= 50;++q) { dp[i][q] += dp[i - 1][q-1]; wa[i][q] += wa[i - 1][q - 1] + (dp[i-1][q-1]* cnt); } cnt *= 2; } cout << dp[31][x] << " " << wa[31][x] << endl; return 0; }