Cakes and Donuts

Problem Link

Solution by TioPatinhas100 pts

Code / Notes

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int ans = 0;
    if(n < 4) {
        cout << "No";
        ans++;
    }
    if(n>4 and n<7) {
        cout << "No";
        ans++;
    }
    for(int c = 0; c <= n/4; c++) {
        for(int d = 0; d <= n/7; d++) {
            if(c*4 + d*7 == n) {
                if(ans==0) { 
                cout << "Yes";
                ans++;
                }
            }
        }
    
    }
    if (ans == 0) {cout << "No";}
}

Last updated 3 weeks, 3 days ago


« Back to problem