728x90
브루트포스 문제입니다.
2중 for문을 통해서 모든 경우의수를 확인했습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int num;
int count = 0;
vector <int> v;
while (1) {
cin >> num;
if (num == -1) {
break;
}
if (num == 0) {
for (int i = 0; i < v.size(); ++i) {
for (int j = 0; j < v.size(); ++j) {
if (v[j] * 2 == v[i]) {
++count;
}
}
}
cout << count << endl;
count = 0;
v.clear();
}
else {
v.push_back(num);
}
}
return 0;
}
'알고리즘' 카테고리의 다른 글
[C++] 백준 2789번 유학 금지 (0) | 2019.09.24 |
---|---|
[C++] 백준 2822번 점수 계산 (0) | 2019.09.24 |
[C++] 백준 6321번 IBM 빼기 1 (0) | 2019.09.23 |
[C++] 백준 6378번 디지털 루트 (0) | 2019.09.23 |
[C++] 백준 6679번 싱기한 네자리 숫자 (0) | 2019.09.23 |