結果
| 問題 |
No.2846 Birthday Cake
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 22:17:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 1,066 bytes |
| コンパイル時間 | 1,630 ms |
| コンパイル使用メモリ | 173,400 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-08-23 22:17:23 |
| 合計ジャッジ時間 | 3,411 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
SetupIO() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(30);
}
} setup_io;
using dd = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<dd>;
using vvd = vector<vd>;
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a%b);
}
int main(void) {
int k, n;
cin >> k >> n;
ll ans = 0;
set<int> s = {13, 17, 19, 23};
if(s.find(k) != s.end()) ans++;
ll mul = 16*9*5*7*11;
vector<ll> dp(mul+1, 0);
dp[0] = 1;
rep(i, 0, k) {
vector<ll> ndp(mul+1, 0);
rep(j, 1, n+1) {
if(mul % j != 0) continue;
rep(l, 0, mul) {
if(l + mul / j <= mul) ndp[l + mul / j] += dp[l];
}
}
swap(dp, ndp);
}
cout << dp[mul] + ans << '\n';
}