Topic link a.holidays (codeforces 670A) train of Thought
First, if 7 7 can divide n, the minimum vacation days M1 M1 and the maximum vacation days m2 m2 are equal to 2xn7 2 \times \frac{n}{7}. "Divide" prompts us to classify n n divided by the remainder of 7 7: The remainder is 0 0, m1=m2=2xn7 m1 = m2 = 2 \times \frac{n}{7}. The remainder is 1 1, considering the extra day is not the weekend, m1=2xn7,m2=2xn7+1 m1 = 2 \times \frac{n}{7}, m2 = 2 \times \frac{n}{7} + 1. The remainder is 6 6, consider the extra 6 days must have weekend, consider 1 days weekend or 2 days weekend, m1=2xn7+1,m2=2xn7+2 m1 = 2 \times \frac{n}{7} + 1, m2 = 2 \times \frac{n}{7} + 2. Other remainder, consider whether there is a weekend of extra days, m1=2xn7,m2=2xn7+2 m1 = 2 \times \frac{n}{7}, m2 = 2 \times \frac{n}{7} + 2. Code
#include <bits/stdc++.h>
using namespace std;
int N, T, D, M1, M2;
int main () {
scanf ("%d", &n);
t = N/7;
d = n% 7;
if (d = = 0) {
m1 = 2 * t;
m2 = 2 * t;
}
else if (d = = 1) {
M1 = 2 * t;
m2 = 2 * t + 1;
}
else if (d = = 6) {
M1 = 2 * t + 1;
m2 = 2 * t + 2;
}
else {
M1 = 2 * t;
m2 = 2 * t + 2;
}
printf ("%d%d\n", M1, M2);
return 0;
}
B. Game of Robots (codeforces 670B)
train of Thought
This problem is equivalent to having n n individuals, everyone should count off. I am going to quote from 1 1 to