목록Algorithm/C++ (148)
cgy12306
#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, K, a, A[21] = { 0, }; char comma; cin >> N >> K; cin >> A[0]; for (int j = 1; j > comma >> a; A[j] = a; } for (int i = 0; i < K; i++) { for (int j = 0; j < N - i - 1; j++) { A[j] = A[j + 1] - A[j]; } } cout
#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int M, X, Y, res = 1; cin >> M; for (int i = 0; i > X >> Y; if (res == X) { res = Y; } else if (res == Y) { res = X; } else { res = res; } } cout
#include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N, M, num; vector::iterator up, low; vector A, B; cin >> N; for (int i = 0 ; i > num; A.push_back(num); } cin >> M; for (int i = 0; i > num; B.push_back(num); } sort(A.begin(), A.end()); for (auto iter = B.begin(); iter != B.end(); ++iter)..
#include #include #include using namespace std; int N, M, num; vector A, B, check; int search(int target) { int start = 0, end, mid; end = A.size() - 1; while (start target) end = mid - 1; else if (A[mid] == target) return 1; } return 0; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N; for (int i = 0; i > num; A.push_back(num); } cin >> M; for..