diff --git a/2201/220102.cpp b/2201/220102.cpp new file mode 100644 index 0000000..7a775ba --- /dev/null +++ b/2201/220102.cpp @@ -0,0 +1,20 @@ +#include +#include + +class Solution { +public: + static int numPairsDivisibleBy60(const std::vector& time) { + int bucket[61]{0}; + for (const auto& i : time) + ++bucket[i % 60]; + int ret = bucket[0] * (bucket[0] - 1) / 2 + bucket[30] * (bucket[30] - 1) / 2; + for (int i = 1; i < 30; ++i) + ret += bucket[i] * bucket[60 - i]; + return ret; + } +}; + +int main() { + std::cout << Solution::numPairsDivisibleBy60({60,60,60}); + return 0; +} diff --git a/2201/CMakeLists.txt b/2201/CMakeLists.txt index 20e68cc..01825ae 100644 --- a/2201/CMakeLists.txt +++ b/2201/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2201) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2201 220102-CN.cpp) \ No newline at end of file +ADD_EXECUTABLE(2201 220102.cpp) \ No newline at end of file