diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5a792bc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}] + +cpp_generate_documentation_comments = xml + +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +#indent_style = space +indent_style = tab +indent_size = 4 +tab_width= 4 diff --git a/Convention/[Runtime]/Config.hpp b/Convention/[Runtime]/Config.hpp index b2fda12..86f7df0 100644 --- a/Convention/[Runtime]/Config.hpp +++ b/Convention/[Runtime]/Config.hpp @@ -1,4 +1,4 @@ -#pragma once +#pragma once #ifndef Convention_Runtime_Config_hpp #define Convention_Runtime_Config_hpp #pragma warning(disable : 4267) @@ -1733,7 +1733,7 @@ namespace Convention elements = std::forward(value); } template>, size_t> = 0 > + std::enable_if_t, size_t> = 0 > void SetValue(const Arg & value) noexcept { static_assert(index == 0, "Index out of bounds for ElementTuple."); diff --git a/Convention/[Runtime]/Generics/NTree.hpp b/Convention/[Runtime]/Generics/NTree.hpp index fc777a9..a81021a 100644 --- a/Convention/[Runtime]/Generics/NTree.hpp +++ b/Convention/[Runtime]/Generics/NTree.hpp @@ -1,4 +1,4 @@ -#pragma once +#pragma once #ifndef Convention_Runtime_Generics_NTree_hpp #define Convention_Runtime_Generics_NTree_hpp diff --git a/Convention/[Runtime]/Generics/Sequence.hpp b/Convention/[Runtime]/Generics/Sequence.hpp index a12ddd9..0150f86 100644 --- a/Convention/[Runtime]/Generics/Sequence.hpp +++ b/Convention/[Runtime]/Generics/Sequence.hpp @@ -9,13 +9,172 @@ namespace Convention namespace Generics { + class IIterator + { + public: + + }; + + template + class ISequence + { + public: + virtual ~ISequence() {} + virtual IIterator begin() abstract; + virtual IIterator end() abstract; + }; + + /** + * @brief 序列容器枚举 + * @tparam Sequence 序列类型 + * @tparam _Index 索引类型 + * @version BS 0.0.1 + */ + template + class SequenceIterator + { + private: + const Sequence& target; + _Index index; + public: + SequenceIterator(const Sequence& target, _Index index) :__init(target), __init(index) {} + SequenceIterator(const SequenceIterator& other) : target(other.target), index(other.index) {} + SequenceIterator& operator=(const SequenceIterator& other) + { + target = other.target; + index = other.index; + return *this; + } + bool operator==(const SequenceIterator& other) noexcept + { + return other.index == index; + } + bool operator!=(const SequenceIterator& other) noexcept + { + return other.index != index; + } + SequenceIterator& operator++() noexcept + { + ++index; + return *this; + } + SequenceIterator operator++(int) noexcept + { + ++index; + return SequenceIterator(target, index - 1); + } + SequenceIterator& operator--() noexcept + { + --index; + return *this; + } + SequenceIterator operator--(int) noexcept + { + --index; + return SequenceIterator(target, index + 1); + } + }; + + /** + * @brief 序列容器可枚举类型 + * @tparam Sequence 序列类型 + * @tparam _Index 索引类型 + * @version BS 0.0.1 + */ + template + struct SequenceRange + { + using iterator = SequenceIterator; + iterator mbegin, mend; + SequenceRange(const Sequence& target, _Index begin = 0, _Index end = 0ll - 1) :mbegin(target, begin), mend(target, end) {} + + constexpr iterator begin() + { + return mbegin; + } + constexpr iterator end() + { + return mend; + } + }; + + + /** + * @brief 栈上静态数组 + * @tparam Element 内容物类型 + * @tparam size 元素大小 + * @version BS 0.0.1 + */ template using Array = std::array; + /** + * @brief 栈上静态Bool数组 + * @tparam size 元素大小 + * @version BS 0.0.1 + */ + template + class BoolArray + : private Array< + std::conditional_t, + capacity / sizeof(std::conditional_t) + (capacity % sizeof(std::conditional_t) ? 1 : 0) + > + { + private: + constexpr static const char* out_of_range_message = "out of range, capacity: "; + using _MyElementTy = std::conditional_t; + constexpr static size_t _MyCapacity = capacity / sizeof(_MyElementTy) + (capacity % sizeof(_MyElementTy) ? 1 : 0); + using _Mybase = Array<_MyElementTy, _MyCapacity>; + constexpr _Mybase& _GetBaseArray() noexcept + { + return *this; + } + constexpr const _Mybase& _GetBaseArray() const noexcept + { + return *this; + } + public: + inline constexpr size_t size() const noexcept + { + return capacity; + } + int ReadValue(size_t index) const + { + if (index < capacity) + { + size_t i = index / sizeof(_MyElementTy), offset = index % sizeof(_MyElementTy); + return _GetBaseArray()[i] & (1ll << offset); + } + throw std::out_of_range(StringIndicator::Combine(out_of_range_message, capacity)); + } + bool operator[](int index) const + { + return ReadValue(index < 0 ? capacity + index : index); + } + void WriteValue(size_t index, bool value) + { + if (index < capacity) + { + size_t i = index / sizeof(_MyElementTy), offset = index % sizeof(_MyElementTy); + if (value) + _GetBaseArray()[i] |= 1ll << offset; + else + _GetBaseArray()[i] &= ~(1ll << offset); + } + throw std::out_of_range(StringIndicator::Combine(out_of_range_message, capacity)); + } + }; + + /** + * @brief 堆上动态数组 + * @tparam Element 内容物类型 + * @tparam Allocator 内存分配器 + * @version BS 0.0.1 + */ template class Allocator> using Vector = std::vector>; } } -#endif Convention_Runtime_Generics_Sequence_hpp \ No newline at end of file +#endif Convention_Runtime_Generics_Sequence_hpp diff --git a/Convention/[Runtime]/Generics/Stack.hpp b/Convention/[Runtime]/Generics/Stack.hpp new file mode 100644 index 0000000..522b312 --- /dev/null +++ b/Convention/[Runtime]/Generics/Stack.hpp @@ -0,0 +1,20 @@ +#pragma once +#ifndef Convention_Runtime_Generics_Sequence_hpp +#define Convention_Runtime_Generics_Sequence_hpp + +#include"Generics/Sequence.hpp" + +namespace Convention +{ + namespace Generics + { + + class Stack + { + + }; + + } +} + +#endif Convention_Runtime_Generics_Sequence_hpp diff --git a/[Test]/CMakeLists.txt b/[Test]/CMakeLists.txt index 90416b0..0266656 100644 --- a/[Test]/CMakeLists.txt +++ b/[Test]/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable(TEST test.cpp) +add_executable(TEST test.cpp "test_sequence.cpp") include_directories(${PROJECT_SOURCE_DIR}/Convention/[Runtime]) -install(TARGETS TEST +install(TARGETS TEST RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) \ No newline at end of file diff --git a/[Test]/test.cpp b/[Test]/test.cpp index a80d648..dec793c 100644 --- a/[Test]/test.cpp +++ b/[Test]/test.cpp @@ -1,6 +1,41 @@ -#include"Config.hpp" +//#include"Config.hpp" +using namespace std; + +#include +#include +#include +using namespace std; + +using ll = long long; +int n = 0; +const int N = 1e6 + 2; +ll a[N], f[N]; int main() { - -} \ No newline at end of file + // 请在此输入您的代码 + map flag; + cin >> n; + f[1] = 1; + f[2] = 1; + for (int i = 3; i <= n; i++) + { + f[i] = f[i - 1] + f[i - 2]; + } + for (int i = 1; i <= n; i++) + { + int temp = 0; + cin >> temp; + if (temp % f[i] == 0) + { + flag[temp / f[i]]++; + } + } + int maxs = 0; + for (auto i = flag.begin(); i != flag.end(); ++i) + { + maxs = max(maxs, i->second); + } + cout << n - maxs; + return 0; +} diff --git a/[Test]/test_sequence.cpp b/[Test]/test_sequence.cpp new file mode 100644 index 0000000..4003783 --- /dev/null +++ b/[Test]/test_sequence.cpp @@ -0,0 +1,9 @@ +#include"Generics/Sequence.hpp" + +using namespace Convention::Generics; +using namespace std; + +void main1() +{ + +}