8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 45b7d31 + 24df7f0 commit f07afc0Copy full SHA for f07afc0
0x12/solutions/2839.cpp
@@ -1,11 +1,29 @@
1
-// Authored by : BaaaaaaaaaaarkingDog
+// Authored by : haneulkimdev
2
// Co-authored by : -
3
-// http://boj.kr/****************
+// http://boj.kr/3649d2bc821d41be958cb51fc82946d3
4
#include <bits/stdc++.h>
5
using namespace std;
6
7
-int main(void){
+int main(void) {
8
ios::sync_with_stdio(0);
9
cin.tie(0);
10
-
11
-}
+ int n;
+ cin >> n;
12
+ int ans = 0;
13
+ while (n >= 0) {
14
+ if (n % 5 == 0) {
15
+ ans += n / 5;
16
+ cout << ans;
17
+ return 0;
18
+ }
19
+ n -= 3;
20
+ ans++;
21
22
+ cout << -1;
23
+}
24
+
25
+/*
26
+3킬로그램 5개는 5킬로그램 3개로 치환이 되기 때문에 3킬로그램은 4개 이하로 사용하면 된다.
27
+n이 5의 배수가 될 때 까지 3으로 빼주면 되는데, 이 때 n이 음수가 된다면
28
+정확하게 n킬로그램을 만들 수 없는 상황이다.
29
+*/
0 commit comments