diff options
Diffstat (limited to 'inf/lige/3/4.c')
-rw-r--r-- | inf/lige/3/4.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/inf/lige/3/4.c b/inf/lige/3/4.c new file mode 100644 index 0000000..d92ebd3 --- /dev/null +++ b/inf/lige/3/4.c @@ -0,0 +1,67 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#define I unsigned long long int +/* +I nasl (I cur) { + char buf[255]; + int len = sprintf(buf, cur); + I tmp = cur; + I cnt = 0; + while (tmp % 10 == 9) { + cnt++; + if (tmp == 9) + return pow(10, cnt)+1; + tmp /= 10; + } + for (int i = 0; i < len/2; i++) + buf[len-i-1] = buf[i]; + if (atoll(buf) <= cur) { + int i = len/2-1; + int j = len/2; + int carry = 0; + while (i >= 0) { + if (buf[i] == '9') { + buf[i] = '0'; + carry++; + } + buf[j++] = buf[i--]; + } + if (buf[len/2] == '9') { + if len + buf[len/2] = '0'; + buf[len/2] = '0'; + } + } +} +*/ +int main (void) { + char buf[255]; + fgets(buf, 255, stdin); + char * c = buf; + I z = strtoull(c, &c, 10); + c++; + I k = strtoull(c, &c, 10); + // I palind = nasl(z-1); + for (I i = z; i <= k; i++) { + /* if (i == palind) { + puts("Palindrom!\n"); + palind = nasl(i); + continue; + } */ + char s[512]; + int l = sprintf(s, "%llu", i); + if (l < 1) { + puts("Palindrom!"); + continue; + } + for (int j = 0; j < l/2; j++) + if (s[j] != s[l-j-1]) { + puts(s); + goto c; + } + puts("Palindrom!"); + c: + ; + } +} |