VioletaBabel
4641번: Doubles 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include<cstdio> #include<algorithm> using namespace std; int main() { int num[100], in = 1, count, max, ans; while (1) { ans = 0; count = 0; max = 0; do { scanf("%d", &in); if (in == -1) return 1; num[count++] = in; } while (in != 0); sort(num, num + count - 1); max = num[count - 2]; max /= 2; for (int i = 0; num[i] <= max; ++i) for (int j = i + 1; j < count - 1; ++j) { if (num[i] * 2 == num[j]) { ++ans; break; } else if (num[i] * 2 < num[j]) break; } printf("%d\n", ans); } } | cs |
'백준 > 백준-C++' 카테고리의 다른 글
1003번: 피보나치 함수 (0) | 2018.06.26 |
---|---|
2217번: 로프 (0) | 2018.03.20 |
1748번: 수 이어 쓰기 1 (0) | 2018.03.15 |
1966번: 프린터 큐 (0) | 2018.03.15 |
1018번: 체스판 다시 칠하기 (0) | 2018.03.13 |
Comments