#include #include #include #include #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; }