diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-01-13 17:25:46 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-01-13 17:25:46 +0100 |
commit | 9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026 (patch) | |
tree | ff24d4ce2b5c11ddafa8932edacbc4588dd927b0 /inf/zotks/2.c | |
parent | fizvaje56 (diff) | |
download | sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.tar sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.tar.gz sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.tar.bz2 sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.tar.lz sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.tar.xz sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.tar.zst sola-gimb-4-9e3cdb5da0b4fc1ff3b0fca15b4118785aebe026.zip |
Diffstat (limited to 'inf/zotks/2.c')
-rw-r--r-- | inf/zotks/2.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/inf/zotks/2.c b/inf/zotks/2.c new file mode 100644 index 0000000..6f71e5b --- /dev/null +++ b/inf/zotks/2.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <signal.h> +#define N unsigned long long int +N s (N n) { + return (n*(n+1))/2; +} +int main (void) { + char buf[256]; + fgets(buf, 256, stdin); + while (1) { + fgets(buf, 256, stdin); + if (ferror(stdin) || feof(stdin)) + break; + char * c; + N n = strtoull(buf, &c, 10); // imamo n števil + N m = strtoull(++c, &c, 10); // vsota vseh teh n števil je m + N k = strtoull(++c, NULL, 10); // teh n števil razdelimo v k skupin + if (k > n) { // ni možno imeti več skupin kot elementov + fprintf(stdout, "NE\n"); + continue; + } + N smallest_max_in_group = n / k; + // fprintf(stderr, "smallest_max_in_group: %llu, s(smig+1)\n", smallest_max_in_group); + if ((n % k)*s(smallest_max_in_group+1) + (k-(n % k))*s(smallest_max_in_group) > m) + fprintf(stdout, "NE\n"); + else + fprintf(stdout, "DA\n"); + } + return 0; +} |