-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.c
More file actions
36 lines (24 loc) · 640 Bytes
/
Copy path2.c
File metadata and controls
36 lines (24 loc) · 640 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
33
34
35
36
#include<stdio.h>
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
int main()
{
printf("Elf Paper Packer\n");
FILE *fp;
int w, h, l;
int sa, sb, sc;
int buffer, needed;
long needed_total = 0;
fp = fopen("input", "r");
while (fscanf(fp,"%dx%dx%d", &w, &h, &l) == 3) {
printf("%d %d %d\n", w, h, l);
sa = w * h;
sb = h * l;
sc = w * l;
buffer = MIN(sa, MIN(sb, sc));
needed = 2 * sa + 2 * sb + 2 * sc + buffer;
needed_total += needed;
printf("Needed: %d\n", needed);
}
printf("Needed total: %ld\n", needed_total);
fclose(fp);
}