提出 #33848661
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 998244353
#define rep(i,a,n) for (ll i=a;i<(ll)n;i++)
ll read(){ll r;scanf("%lld",&r);return r;} // read
const int N = 5000;
ll f[N+10][N+10]; // f[i][j] = 前i个(第i个不为0), sum(i*Bi) = j 方案数
ll sum[N+10][N+10]; // sum[i][j] = sum f[i-m+1..i][j], 对i维度的滑窗和(也可以前缀和)
int main() {
int n = read();
int m = read();
f[0][0] = sum[0][0] = 1;
rep(i,1,n+1) rep(j,0,n+1) {
// f[i][j] = sum f[i-m ~ i-1][j - i * bi] , k = bi * i, O(log)
for(int k = i; k <= j; k+=i) (f[i][j] += sum[i-1][j-k]) %= MOD;
sum[i][j] = (sum[i-1][j] + f[i][j] - (i-m>=0?f[i-m][j]:0)) % MOD; // 长度m的滑窗
}
rep(i,1,n+1) printf("%lld\n", (f[i][n] + MOD) % MOD);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | H - Count Multiset |
| ユーザ | cromarmot |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 600 |
| コード長 | 793 Byte |
| 結果 | AC |
| 実行時間 | 533 ms |
| メモリ | 316020 KiB |
コンパイルエラー
./Main.cpp: In function ‘ll read()’:
./Main.cpp:8:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
8 | ll read(){ll r;scanf("%lld",&r);return r;} // read
| ~~~~~^~~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 600 / 600 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, example0.txt, example1.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 110 ms | 73048 KiB |
| 001.txt | AC | 374 ms | 234220 KiB |
| 002.txt | AC | 396 ms | 252516 KiB |
| 003.txt | AC | 258 ms | 170128 KiB |
| 004.txt | AC | 231 ms | 151764 KiB |
| 005.txt | AC | 349 ms | 225352 KiB |
| 006.txt | AC | 346 ms | 223320 KiB |
| 007.txt | AC | 235 ms | 152048 KiB |
| 008.txt | AC | 196 ms | 126684 KiB |
| 009.txt | AC | 220 ms | 143580 KiB |
| 010.txt | AC | 527 ms | 315708 KiB |
| 011.txt | AC | 519 ms | 315964 KiB |
| 012.txt | AC | 520 ms | 315960 KiB |
| 013.txt | AC | 526 ms | 316016 KiB |
| 014.txt | AC | 530 ms | 315728 KiB |
| 015.txt | AC | 524 ms | 315648 KiB |
| 016.txt | AC | 526 ms | 315596 KiB |
| 017.txt | AC | 531 ms | 315952 KiB |
| 018.txt | AC | 517 ms | 315924 KiB |
| 019.txt | AC | 519 ms | 315724 KiB |
| 020.txt | AC | 520 ms | 315996 KiB |
| 021.txt | AC | 517 ms | 315276 KiB |
| 022.txt | AC | 523 ms | 315992 KiB |
| 023.txt | AC | 518 ms | 315808 KiB |
| 024.txt | AC | 521 ms | 316008 KiB |
| 025.txt | AC | 521 ms | 315572 KiB |
| 026.txt | AC | 522 ms | 315792 KiB |
| 027.txt | AC | 525 ms | 315604 KiB |
| 028.txt | AC | 520 ms | 315288 KiB |
| 029.txt | AC | 352 ms | 224192 KiB |
| 030.txt | AC | 329 ms | 212340 KiB |
| 031.txt | AC | 324 ms | 208848 KiB |
| 032.txt | AC | 260 ms | 166672 KiB |
| 033.txt | AC | 433 ms | 272992 KiB |
| 034.txt | AC | 2 ms | 3624 KiB |
| 035.txt | AC | 513 ms | 308048 KiB |
| 036.txt | AC | 512 ms | 308300 KiB |
| 037.txt | AC | 508 ms | 308196 KiB |
| 038.txt | AC | 499 ms | 308272 KiB |
| 039.txt | AC | 503 ms | 308044 KiB |
| 040.txt | AC | 502 ms | 308184 KiB |
| 041.txt | AC | 510 ms | 308044 KiB |
| 042.txt | AC | 505 ms | 308132 KiB |
| 043.txt | AC | 509 ms | 308192 KiB |
| 044.txt | AC | 511 ms | 308164 KiB |
| 045.txt | AC | 513 ms | 308192 KiB |
| 046.txt | AC | 508 ms | 308048 KiB |
| 047.txt | AC | 533 ms | 316020 KiB |
| 048.txt | AC | 524 ms | 315916 KiB |
| 049.txt | AC | 530 ms | 315964 KiB |
| example0.txt | AC | 5 ms | 3732 KiB |
| example1.txt | AC | 2 ms | 3692 KiB |