repositories
/
advent21.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
speed up
[advent21.git]
/
06b.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
5
int
main
()
6
{
7
char
buf
[
1000
];
8
if
(
fgets
(
buf
,
1000
,
stdin
) ==
NULL
)
9
return
1
;
10
long
fish
[
9
] = {
0
};
11
char
*
p
=
strtok
(
buf
,
","
);
12
fish
[
atoi
(
p
)]++;
13
while
((
p
=
strtok
(
NULL
,
","
)) !=
NULL
)
14
fish
[
atoi
(
p
)]++;
15
16
for
(
long
day
=
0
;
day
<
256
;
day
++)
17
fish
[(
day
+
7
) %
9
] +=
fish
[
day
%
9
];
18
19
long
sum
=
0
;
20
for
(
long
i
=
0
;
i
<=
8
;
i
++)
21
sum
+=
fish
[
i
];
22
printf
(
"%lu
\n
"
,
sum
);
23
}