https://www.acmicpc.net/problem/2839
초기 시도
#include <iostream>
using namespace std;
int main() {
int n, a3=0, a5=0;
cin >> n;
while(n){
if (n%5==0){
a5 = n/5;
break;
}
a3 += 1 ;
n -= 3;
}
if (n<0) cout << -1;
else cout << a5+a3;
}
#include <iostream>
using namespace std;
int main() {
int n, a3=0;
cin >> n;
while(n>0 && n%5!=0){
a3 += 1 ;
n -= 3;
}
if (n<0) cout << -1;
else cout << a3+n/5;
}
#include<stdio.h>
int main(void){
int N, i;
scanf("%d",&N);
for(i=0; N>=0 && N%5; N-=3, i++);
if(N<0) printf("-1");
else printf("%d",i+(N/5));
}
이해아니감~~
#include <iostream>
main(){int n;std::cin >> n;(n==4||n==7) ? std::cout<<"-1":std::cout<<n-2*n/5*2;}
N=int(input())
divFiv=N//5
n=N%5
while divFiv>=0:
if n%3 ==0:
three=n//3
n%=3
break
divFiv-=1
n+=5
print((n==0) and (divFiv+three) or -1)
N=int(input())
t=0
while N>0 and N%5 != 0:
t += 1
N -= 3
if N<0: print(-1)
else: print(t+N//5)
이해아니감~~
n=int(input())
print(-(n in[4,7])or n-2*n//5*2)