結果
問題 |
No.1011 Infinite Stairs
|
ユーザー |
![]() |
提出日時 | 2020-04-26 17:13:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 1,886 ms |
コンパイル使用メモリ | 173,604 KB |
実行使用メモリ | 40,320 KB |
最終ジャッジ日時 | 2024-11-17 13:44:31 |
合計ジャッジ時間 | 65,607 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 4 TLE * 20 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; map<int, ll> memo; int d; ll rec(int n, int k){ int arg = n * 400 + k; if(memo.count(arg) == 1) return memo[arg]; if(n == 0 && k == 0) return memo[arg] = 1; ll ret = 0; for(int i = 1; i <= d && k - i >= 0; i++){ ret += rec(n - 1, k - i); ret %= MOD; } return memo[arg] = ret; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, k; cin >> n >> d >> k; cout << rec(n, k) << endl; }