結果
問題 |
No.2846 Birthday Cake
|
ユーザー |
![]() |
提出日時 | 2024-08-24 01:50:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 1,315 bytes |
コンパイル時間 | 1,842 ms |
コンパイル使用メモリ | 199,752 KB |
最終ジャッジ日時 | 2025-02-24 00:33:35 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ALL(v) v.begin(),v.end() #define dbg(x) cerr << #x << ": " << (x) << endl; template<class F, class S> ostream& operator<<(ostream& os, pair<F,S>& p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template<class Iter> void print(Iter beg, Iter end) { for (Iter itr = beg; itr != end; ++itr) { cerr << *itr << ' '; } cerr << '\n'; } inline bool naraba(bool a, bool b) { return (!a || b); } int K,N; int main() { cin >> K >> N; int L = 1; for (int i = 1; i <= N; ++i) { if (i==13 || i==17 || i==19 || i==23) continue; L = lcm(L,i); } dbg(L) vector<ll> v; for (int i = 1; i <= N; ++i) { if (i==13 || i==17 || i==19 || i==23) continue; v.push_back(L / i); } vector dp(K+1, vector<ll>(L+1)); dp[0][0] = 1; for (int i = 1; i <= K; ++i) { for (int j = 1; j <= L; ++j) { for (ll use : v) { if (j-use >= 0) { dp[i][j] += dp[i-1][j-use]; } } } } ll ans = dp[K][L]; for (int i : {13,17,19,23}) { if (i <= N) { ans += (K==i); } else { break; } } cout << ans << '\n'; }