-
Codeforces Round #445 (Div. 2, based on Technocup 2018 Elimination Round 3) - A. ACM ICPC코드포스(CodeForce) 2018. 8. 17. 17:36반응형
1. 문제
2. 알고리즘
키워드 - 구현
* 최노키오 소견
재훈씨
인티저 홀수에 나누기 2 를 하면 나머지가 버림이 됩니다. 참고하세요
3. 코드
123456789101112131415161718192021222324252627282930313233343536373839404142#include <iostream>#include <vector>#include <algorithm>#include <functional>#include <string>using namespace std;int main() {vector<int> arr(6);int sum = 0;for (int i=0; i<6; i++) {cin >> arr[i];sum += arr[i];}if (sum % 2 == 1) cout << "NO";else {bool ok = false;for(int i=0; i<6; i++) {for(int j=i+1; j<6; j++) {for(int k=j+1; k<6; k++) {int cand = arr[i] + arr[j] + arr[k];if (cand == sum/2) {ok = true;break;}//cout << arr[i] << " " << arr[j] << " " << arr[k] << " = " << arr[i] + arr[j] + arr[k] << endl;}}}if (ok) {cout << "YES";} elsecout << "NO";}return 0;}cs 반응형'코드포스(CodeForce)' 카테고리의 다른 글
Codeforces Round #459 (Div. 2) - A. Eleven (0) 2018.08.17 Hello 2018 - A. Modular Exponentiation (0) 2018.08.17 Codeforces Round #445 (Div. 2, based on Technocup 2018 Elimination Round 3) - B - Vlad and Cafes (0) 2018.08.17 Codeforces Round #457 (Div. 2) - A. Jamie and Alarm Snooze (0) 2018.08.17 Codeforces Round #449 (Div. 2) - A. Scarborough Fair (0) 2018.08.17