This commit is contained in:
Zengtudor 2024-10-09 12:36:38 +08:00
parent 48ad276a56
commit 82db0d1178

View File

@ -1,11 +1,19 @@
#define NDEBUG
#include <cctype>
#include <iostream>
#include <algorithm>
#include <type_traits>
#define NV(v)#v<<" : "<<(v)
#ifdef NDEBUG
#define DEBUG(code)
#else
#define DEBUG(code){code}
#endif
using ull = unsigned long long;
static const size_t max_n {(size_t)2e3+5};
// static const size_t max_n {(size_t)10};
static ull k, c[max_n][max_n], prefix[max_n][max_n], t, n, m;
static void init(){
@ -16,16 +24,32 @@ static void init(){
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
}
}
DEBUG(
for(ull i{0};i<max_n;i++){
for(ull j{0};j<=i;j++){
std::cout<<c[i][j]<<' ';
}
std::cout<<'\n';
}
std::cout<<"===========\n";
)
for(ull i = 2;i<max_n-1;i++){ //注意这里是max_n-1
for(ull j{1};j<=i;j++){
prefix[i][j] = prefix[i-1][j]+prefix[i][j-1]-prefix[i-1][j-1] + (c[i][j]==0?1:0);
}
}
prefix[i][i+1] = prefix[i][i];
}
DEBUG(
for(ull i{0};i<max_n;i++){
for(ull j{0};j<=i;j++){
std::cout<<prefix[i][j]<<' ';
}
std::cout<<'\n';
}
)
}
#define NV(v)#v<<" : "<<(v)
template<class T>
struct ReadNumber{
ReadNumber& operator>>(T &num){