結果
問題 |
No.2846 Birthday Cake
|
ユーザー |
![]() |
提出日時 | 2024-06-27 16:59:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 800 ms |
コンパイル使用メモリ | 74,604 KB |
最終ジャッジ日時 | 2025-02-22 00:47:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> using namespace std; using ll = long long; int main() { ll K, N; cin >> K >> N; ll max_c = 55440; vector<vector<ll>> dp(K + 1, vector<ll>(max_c + 1, 0)); dp[0][0] = 1; for (ll i = 0; i < K; i++) { for (ll j = 0; j <= max_c; j++) { for (ll k = 1; k <= N; k++) { if (max_c % k != 0) { continue; } ll div = 55440 / k; if (j + div <= max_c) { dp[i + 1][j + div] += dp[i][j]; } } } } ll ans = dp[K][max_c]; if (max_c % K != 0) { ans++; } cout << ans << endl; }