This commit is contained in:
Zengtudor 2024-10-09 15:26:24 +08:00
parent 82db0d1178
commit 9797c78137
2 changed files with 72 additions and 11 deletions

View File

@ -19,7 +19,7 @@ static ull k, c[max_n][max_n], prefix[max_n][max_n], t, n, m;
static void init(){
c[0][0] = c[1][0] = c[1][1] = 1;
for(ull i {2};i<max_n;i++){
c[i][0]=1;
c[i][0]=1;
for(ull j{1};j<=i;j++){
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
}

View File

@ -1,15 +1,76 @@
#include <type_traits>
#define NDEBUG
#include <iostream>
using ull = unsigned long long;
ull t;
#ifndef NDEBUG
#include <stdexcept>
#include <sstream>
#endif
#define NV(v)#v<<" : "<<(v)
using ull = unsigned long long;
#ifdef NDEBUG
#define ARR_NDB_NOEXCEPT noexcept
#define ARR_NDB_CONSTEXPR constexpr
#else
#define ARR_NDB_CONSTEXPR
#define ARR_NDB_NOEXCEPT
#endif
template<size_t a,size_t b>
constexpr bool test(){
return a>=b;
}
template<class T, size_t size>
class Array{
public:
private:
T arr[size];
public:
ARR_NDB_CONSTEXPR T& operator[](const size_t n)ARR_NDB_NOEXCEPT{
#ifndef NDEBUG
if(n>=size){
std::stringstream ss;
ss<<"\nYour [array size] is: "<<size<<"\nBut your [index] is :"<<n<<'\n';
throw std::range_error(ss.str());
}
#endif
return arr[n];
}
ARR_NDB_CONSTEXPR const T& operator[](const size_t n)const ARR_NDB_NOEXCEPT{
#ifndef NDEBUG
if(n>=size){
std::stringstream ss;
ss<<"\nYour [array size] is: "<<size<<"\nBut your [index] is :"<<n<<'\n';
throw std::range_error(ss.str());
}
#endif
return arr[n];
}
ARR_NDB_CONSTEXPR operator const T*()const ARR_NDB_NOEXCEPT{
return arr;
}
constexpr bool is_const()const{
return true;
}
constexpr bool is_const(){
return false;
}
};
constexpr size_t size {10};
constexpr Array<ull,size> arr{};
ull a;
int main(){
std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
std::cout<<NV(t)<<'\n';
std::cin>>t;
std::cout<<NV(t)<<'\n';
}
std::cout<<NV(arr)<<'\n';
// std::cout<<NV(&arr[size-1])<<'\n'<<NV(&a)<<'\n';
// std::cout<<NV(a)<<'\n';
// std::cout<<NV(++arr[size])<<'\n';
// std::cout<<NV(a)<<'\n';
constexpr ull a {arr[size-1]};
const constexpr ull *p {arr};
std::cout<<NV(a)<<'\n'<<NV(p)<<'\n';
}