온라인저지
[BOJ] 14697번: 방 배정하기
plzfday
2018. 4. 9. 22:45
14697번: 방 배정하기
DP로도 풀어도 되고 범위가 굉장히 작기 때문에 Brute force로 풀어도 되는 문제이다.
실력이 정말 부족하기 때문에 이런 Brute force 문제들도 많이 풀어 봐야겠다.
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 | #include <iostream> using namespace std; int main() { cin.sync_with_stdio(false), cout.sync_with_stdio(false); int b[3], n; for (int i = 0; i < 3; ++i) { cin >> b[i]; } cin >> n; for (int i = 0; i <= n / b[2]; i++) { int c = i * b[2]; for (int j = 0; j <= n / b[1]; j++) { int c2 = c + j * b[1]; for (int k = 0; k <= n / b[0]; k++) { int c3 = c2 + k * b[0]; if (c3 == n) { cout << 1; return 0; } } } } cout << 0; return 0; }
|
|