update bug

This commit is contained in:
Zengtudor 2024-10-09 00:53:06 +08:00
parent d97eb12ac3
commit 4220c362fa
2 changed files with 43284 additions and 3 deletions

View File

@ -1,12 +1,84 @@
// #define NDEBUG //切换release和debug版本
#include <cctype> #include <cctype>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <type_traits> #include <type_traits>
#include <sstream>
using ull = unsigned long long; using ull = unsigned long long;
template<class T,size_t size>
struct Array{
constexpr Array(){};
constexpr Array(const std::initializer_list<T> list){
std::copy(list.begin(),list.end(),arr);
}
#ifdef NDEBUG
#define NDB_NOEXCEPT noexcept
#define NDB_CONSTEXPR constexpr
#else
#define NDB_NOEXCEPT
#define NDB_CONSTEXPR
#endif
NDB_CONSTEXPR T& operator[](const size_t n)NDB_NOEXCEPT{
// static_assert(noexcept(Array::operator[](0)), "isn't noexcept");
#ifndef NDEBUG
if(n>=size){
std::ostringstream err_oss;
err_oss<<"\n[array_size]: "<<size<<"\n[Your index]: "<<n<<'\n';
throw std::runtime_error(err_oss.str());
}
#endif
return arr[n];
}
struct Iterator{
constexpr Iterator(const size_t n,T *const p)noexcept:now{n},p{p}{}
bool operator!=(const Iterator &that)const noexcept{
return this->now!=that.now;
}
NDB_CONSTEXPR T& operator*()const NDB_NOEXCEPT{
#ifndef NDEBUG
if(now>=size){
std::ostringstream err_oss;
err_oss<<"[array_size]: "<<size<<" [Your index]: "<<now<<'\n';
throw std::runtime_error(err_oss.str());
}
#endif
return p[now];
}
constexpr Iterator& operator++()noexcept{
now++;
return *this;
}
constexpr Iterator& operator--()noexcept{
now--;
return *this;
}
constexpr Iterator operator--(int)noexcept{
auto old = *this;
now--;
return old;
}
private:
size_t now;
T *const p;
};
constexpr Iterator begin()noexcept{
return Iterator(0,arr);
}
constexpr Iterator end()noexcept{
return Iterator(size,arr);
}
private:
T arr[size];
};
static const size_t max_n {(size_t)2e3+5}; static const size_t max_n {(size_t)2e3+5};
ull k, c[max_n][max_n], prefix[max_n][max_n], t, n, m; ull k, t, n, m;
Array<Array<ull,max_n>,max_n> c,prefix;
static void init(){ static void init(){
c[0][0] = c[1][0] = c[1][1] = 1; c[0][0] = c[1][0] = c[1][1] = 1;
@ -16,11 +88,11 @@ static void init(){
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k; c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
} }
} }
for(ull i = 2;i<max_n;i++){ //t被修改 for(ull i = 2;i<max_n-1;i++){ //t被修改
for(ull j{1};j<=i;j++){ 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][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]; prefix[i][i+1] = prefix[i][i];
} }
} }

43209
test.cpp Normal file

File diff suppressed because it is too large Load Diff