#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[1001] = {0,};
        int nn = n;
    
    for (int i = 1;i < 1001;i++) {
        nn = n;
        int cnt = 1;
        nn %= 5*i;
        while (nn >= 0) {
            nn = nn % 3;
            cnt ++;
        }
        if (nn == 0) {
            a[i] = cnt;
        }
    } 
    int b = 0;
    for (int i =0 ;i < 1001;i++ ) {
        if (a != 0) {
            b =1;
        }
    }
    if (b = 0) {
        if (nn % 3 == 0) {
            cout << nn / 3;
            return 0;
        }
        cout << -1;
    }
    else{
        cout << max(a,a+1001);
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: