main
黄海 1 year ago
parent 2905493de9
commit 83c935bfd0

@ -1,17 +1,24 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int n, cnt;
int main() { int main() {
int n, cnt = 0;
cin >> n; cin >> n;
cnt = n / 3;
if (n == 2) if (n == 2)
cnt = -1; cnt = -1;
else if (n == 4) else if (n == 4)
cnt = 4; cnt = 4;
else if (n == 5)
cnt = 3;
else if (n == 7)
cnt = 3;
else if (n % 3 == 0)
cnt = n / 3;
else if (n % 3 == 1) else if (n % 3 == 1)
cnt += 1; cnt = (n - 7) / 3 + 3;
else if (n % 3 == 2) else if (n % 3 == 2)
cnt += 2; cnt = (n - 5) / 3 + 3;
cout << cnt << endl; cout << cnt << endl;
return 0; return 0;
} }

@ -1,24 +0,0 @@
#include <iostream>
using namespace std;
int n, cnt;
int main() {
cin >> n;
if (n == 2)
cnt = -1;
else if (n == 4)
cnt = 4;
else if (n == 5)
cnt = 3;
else if (n == 7)
cnt = 3;
else if (n % 3 == 0)
cnt = n / 3;
else if (n % 3 == 1)
cnt = (n - 7) / 3 + 3;
else if (n % 3 == 2)
cnt = (n - 5) / 3 + 3;
cout << cnt << endl;
return 0;
}
Loading…
Cancel
Save