結果
| 問題 | 
                            No.2846 Birthday Cake
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tottoripaper
                         | 
                    
| 提出日時 | 2024-08-24 13:28:18 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 127 ms / 2,000 ms | 
| コード長 | 801 bytes | 
| コンパイル時間 | 2,097 ms | 
| コンパイル使用メモリ | 197,440 KB | 
| 最終ジャッジ日時 | 2025-02-24 00:35:49 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 34 | 
ソースコード
#include <bits/stdc++.h>
using ll = std::int64_t;
int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int K, N;
    std::cin >> K >> N;
    const int EXCEPTIONS = (1 << 13) | (1 << 17) | (1 << 19) | (1 << 23);
    const int MAX_DEN = 55440;
    std::vector dp(K + 1, std::vector<ll>(MAX_DEN + 1, 0));
    dp[0][0] = 1;
    for(int i=0;i<K;i++){
        for(int j=0;j<=MAX_DEN;j++){
            for(int k=1;k<=N;k++){
                if(EXCEPTIONS >> k & 1){continue;}
                int num = MAX_DEN / k;
                if(j + num <= MAX_DEN){
                    dp[i + 1][j + num] += dp[i][j];
                }
            }
        }
    }
    ll res = dp[K][MAX_DEN];
    if(EXCEPTIONS >> K & 1){
        res += 1;
    }
    std::cout << res << std::endl;
}
            
            
            
        
            
tottoripaper