Last active
August 28, 2019 03:31
-
-
Save seong-min-s/21b052699eae674abb0e1a15671aef8d to your computer and use it in GitHub Desktop.
백준 2839번 설탕배달
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main(void) | |
{ | |
int n, p, q, r; | |
cin >> n; | |
p = n / 5; | |
q = n % 5; | |
r = q % 3; | |
while (r != 0) | |
{ | |
p--; | |
q += 5; | |
r = q % 3; | |
} | |
r = (p < 0) ? -1 : p + q / 3; | |
cout << r; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment