Skip to content

Instantly share code, notes, and snippets.

@godtaehee
Created May 3, 2019 11:04
Show Gist options
  • Save godtaehee/0edde00e8428ff74399a2b9fe2d29b01 to your computer and use it in GitHub Desktop.
Save godtaehee/0edde00e8428ff74399a2b9fe2d29b01 to your computer and use it in GitHub Desktop.
#2839
#include <iostream>
using namespace std;
int main(){
int N;
int x, y;
int min = 10000;
cin >> N;
x = N/3;
y = N/5;
for(int i = 0; i <= x; i++){
for(int j = 0; j <= y; j++){
if(3 * i + 5 * j == N){
if(min > i+j){
min = i+j;
}
}
}
}
if(min == 10000)
min = -1;
cout << min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment