-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_Lab09_4.c
More file actions
32 lines (31 loc) · 830 Bytes
/
2_Lab09_4.c
File metadata and controls
32 lines (31 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
int gets;
scanf("%d", &gets);
int pigs[6];
for (int j = 0; j < 6; j++) {
scanf("%d", &pigs[j]);
}
int day = 1;
int sums = 0;
for (int j = 0; j < 6; j++) sums += pigs[j];
while (sums <= gets) {
day++;
int prev[6];
for (int j = 0; j < 6; j++) {
prev[j] = pigs[j];
}
for (int j = 0; j < 6; j++) {
pigs[j] += prev[(j + 5) % 6];
pigs[j] += prev[(j + 1) % 6];
pigs[j] += prev[(j + 3) % 6];
}
sums = 0;
for (int j = 0; j < 6; j++) sums += pigs[j];
}
printf("%d\n", day);
}
}