aboutsummaryrefslogtreecommitdiff
path: root/2023/06
diff options
context:
space:
mode:
Diffstat (limited to '2023/06')
-rw-r--r--2023/06/6a.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/2023/06/6a.c b/2023/06/6a.c
index 25a85e5..b3c0ba1 100644
--- a/2023/06/6a.c
+++ b/2023/06/6a.c
@@ -2,30 +2,24 @@
2 2
3#include <inttypes.h> 3#include <inttypes.h>
4#include <math.h> 4#include <math.h>
5#include <stdbool.h>
6#include <stdio.h> 5#include <stdio.h>
7#include <stdlib.h> 6#include <stdlib.h>
8#include <string.h>
9 7
10#define N 100000 8#define N 100000
11 9#define ISNUM(c) (c >= '0' && c <= '9')
12#define MIN(a, b) ((a)<(b)?(a):(b))
13#define MAX(a, b) ((a)>(b)?(a):(b))
14
15bool isnum(char c) { return c >= '0' && c <= '9'; }
16 10
17int64_t readl(int64_t nums[], char *buf) { 11int64_t readl(int64_t nums[], char *buf) {
18 int64_t i; 12 int64_t i;
19 for (i = 0; *buf; buf++) { 13 for (i = 0; *buf; buf++) {
20 if (!isnum(*buf)) continue; 14 if (!ISNUM(*buf)) continue;
21 nums[i++] = atoll(buf); 15 nums[i++] = atoll(buf);
22 while (isnum(*buf)) buf++; 16 while (ISNUM(*buf)) buf++;
23 } 17 }
24 return i; 18 return i;
25} 19}
26 20
27int main() { 21int main() {
28 char line[N], clean[N]; 22 char line[N];
29 int64_t i, n, p, D, x1, x2, t[N], d[N]; 23 int64_t i, n, p, D, x1, x2, t[N], d[N];
30 24
31 n = readl(t, fgets(line, N, stdin)); 25 n = readl(t, fgets(line, N, stdin));

Generated with cgit - Back to sebastiano.tronto.net