알고리즘

[알고리즘] 백준 14697 - 방 배정하기 (C++)

blueberrysoda 2024. 9. 13. 23:10

[문제 링크] : https://www.acmicpc.net/problem/14697

#include <iostream>
using namespace std;

int A, B, C, N;

void solve(){
    for(int i=0; i<=N; i++){
        int a = A * i;
        for(int j=0; j<=N; j++){
            int b = B * j;
            for(int k=0; k<=N; k++){
                int c = C * k;
                if(a + b + c == N){
                    cout << 1 << "\n";
                    return;
                }
            }
        }
    }
    cout << 0 << "\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> A >> B >> C >> N;

    solve();     

    return 0;
}