This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - Power Mode II | |
| - KeyPromoter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| from matplotlib import pyplot as plt | |
| import numpy as np | |
| from sklearn.cluster import * | |
| from sklearn import mixture | |
| from sklearn import metrics | |
| from scipy.stats import mode | |
| class ImgProcessor: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename Comparable> | |
| int binarySearch(const vector<Comparable>& a, const Comparable& x) { | |
| int low = 0, high = a.size() - 1; | |
| while (low <= high) { | |
| int mid = (low + high) / 2; | |
| if (a[mid] < x) | |
| low = mid + 1; | |
| else(a[mid] > x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param a | |
| * @return maxsum | |
| * @brief 最大相连子序列和的 O(n^3) 算法 | |
| */ | |
| int maxSubSum1(const vector<int> &a) { | |
| int maxSum = 0; | |
| for (int i = 0; i < a.size(); ++i) | |
| for (int j = i; j < a.size(); ++j) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param a | |
| * @return maxsum | |
| * @brief 最大相连子序列和的 O(n^2) 算法 | |
| */ | |
| int maxSubSum2(const vector<int> &a) { | |
| int maxSum = 0; | |
| for (int i = 0; i < a.size(); ++i) { | |
| int thisSum = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @param a | |
| * @param left | |
| * @param right | |
| * @return maxSum between left and right | |
| * @brief 相连最大子序列和的递归算法 | |
| * @note 找出生成 [left ... right] 的子数组的最大和,不试图保留具体的最佳序列 | |
| */ | |
| int maxSumRec(const vector<int> &a, int left, int right) { | |
| if (left == right) // 基准情形 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long long gcd(long long m, long long n) { | |
| while (n != 0) { | |
| long long rem = m % n; | |
| m = n; | |
| n = rem; | |
| } | |
| return m; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long long pow(long long x, int n) { | |
| if (n == 0) | |
| return 1; | |
| if (n == 1) | |
| return x; | |
| if (n & 0x1) | |
| return pow(x * x, n / 2) * x; | |
| else | |
| return pow(x * x, n / 2); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename Object> | |
| class Vector { | |
| private: | |
| int theSize; | |
| int theCapacity; | |
| Object *objects; | |
| static const int SPARE_CAPACITY = 16; | |
| public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template<typename Object> | |
| struct Node { | |
| Object data; | |
| Node *prev; | |
| Node *next; | |
| Node(const Object &d = Object{}, Node *p = nullptr, Node *n = nullptr) | |
| : data{d}, prev{p}, next{n} {} | |
| Node(Object &&d, Node *p = nullptr, Node *n = nullptr) |
OlderNewer