summaryrefslogtreecommitdiffstats
path: root/inf
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2021-11-01 17:56:29 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2021-11-01 17:56:29 +0100
commit43e520c0234f0f31a726a6f5a852f0bc7f1758dc (patch)
treed6b2ac7b33bd914740561ed4731493b214f9e863 /inf
parentrsa malo teksta (diff)
downloadsola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.tar
sola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.tar.gz
sola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.tar.bz2
sola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.tar.lz
sola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.tar.xz
sola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.tar.zst
sola-gimb-3-43e520c0234f0f31a726a6f5a852f0bc7f1758dc.zip
Diffstat (limited to 'inf')
-rw-r--r--inf/priprave/dn/.gitignore4
-rw-r--r--inf/priprave/dn/1a.c26
-rw-r--r--inf/priprave/dn/1b.c34
-rw-r--r--inf/priprave/dn/Makefile15
4 files changed, 79 insertions, 0 deletions
diff --git a/inf/priprave/dn/.gitignore b/inf/priprave/dn/.gitignore
new file mode 100644
index 0000000..a32bbeb
--- /dev/null
+++ b/inf/priprave/dn/.gitignore
@@ -0,0 +1,4 @@
+*
+!*/
+!*.*
+!Makefile
diff --git a/inf/priprave/dn/1a.c b/inf/priprave/dn/1a.c
new file mode 100644
index 0000000..84b2c08
--- /dev/null
+++ b/inf/priprave/dn/1a.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+/* https://codeforces.com/group/Eu6CNrz8hK/contest/349888/problem/A */
+int main (void) { /* TIL: od ISO C11 je to legalno */
+ unsigned short int num1 = 9;
+ unsigned short int num2 = 10;
+ int c;
+ while (getchar() != '\n');
+ while (1) {
+ if ((c = getchar()) == EOF)
+ break;
+ if (c == '\n')
+ num2 = 9;
+ if (c <= '9' && c >= '1')
+#define num (*(num2 > 9 ? &num1 : &num2))
+ if (c-'0' < num)
+ num = c-'0';
+ }
+ if (num1 == num2)
+ printf("%d\n", num1);
+ else if (num1 < num2)
+ printf("%d%d\n", num1, num2);
+ else
+ printf("%d%d\n", num2, num1);
+ return 0;
+}
diff --git a/inf/priprave/dn/1b.c b/inf/priprave/dn/1b.c
new file mode 100644
index 0000000..8f4f4d3
--- /dev/null
+++ b/inf/priprave/dn/1b.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+int main (void) {
+ int a, b, n;
+ char buf[128];
+ char * cp = buf;
+ fgets(buf, 128, stdin);
+ buf[128] = '\0';
+ a = strtol(cp, &cp, 10);
+ if (!cp)
+ return 1;
+ cp++;
+ b = strtoll(cp, &cp, 10);
+ if (!cp)
+ return 2;
+ n = strtol(cp, &cp, 10);
+ if (a == 0) {
+ puts("5\n");
+ return 0;
+ }
+ if (b%a) {
+ puts("No solution\n");
+ return 0;
+ }
+ b /= a;
+ for (int i = -1000; i <= 1000; i++) /* mam 2 sekundi */
+ if (pow(i, n) == b) {
+ printf("%d\n", i);
+ return 0;
+ }
+ puts("No solution\n");
+ return 0;
+}
diff --git a/inf/priprave/dn/Makefile b/inf/priprave/dn/Makefile
new file mode 100644
index 0000000..1dd50ea
--- /dev/null
+++ b/inf/priprave/dn/Makefile
@@ -0,0 +1,15 @@
+CFLAGS += -Wextra -Wall -pedantic -g -O0 -finput-charset=UTF-8 -fanalyzer -fextended-identifiers
+LDFLAGS += -lm
+CC ?= cc
+SHELL ?= /bin/sh
+cbins := $(subst .c,,$(wildcard *.c))
+asmbins := $(subst .asm,,$(wildcard *.asm))
+default: $(cbins) $(asmbins)
+%: %.c
+ $(CC) $(CFLAGS) $< -o$@ $(LDFLAGS)
+%: %.asm
+ # za zdaj sicer še ni ničesar v zbornem jeziku, mogoče pa bo ...
+ nasm -f elf $< && ld -m elf_i386 -s -o $@ $@.o
+.PHONY: clean
+clean:
+ rm -f $(bins) $(asmbins) *.o