3 ms·
#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> static
by tubs 13y ago
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
static char c[9];
int p(int i)
{
putchar(c[i++]);
putchar(c[i++]);
putchar(c[i+(7-i)]);
putchar(c[i+(8-i)]);
return 0;
}
int f(int i, int x) {
i -= x;
if(!i) { return p(x); }
if(i<0) return i+x;
return x + (f(i,x) ?: - x);
}
int d(int a, int b)
{
return a-b?d(--a,b)+1:0;
}
void x(int i)
{
if(f(i,3)&f(i,5))printf("%d",i);
printf("\n");
}
int i( int c, int target, void (*fn)(int i) )
{
return d(target+1,c)?({ fn(c); i(++c,target,fn); }):0;
}
int main( int argc, char **argv )
{
int fd=open(argv[0], O_RDONLY);
char *m=mmap(NULL,20000,PROT_READ,MAP_PRIVATE,fd,0);
c[3] = (char)(0x20|m[3]);
c[4] = m[342];
c[5] = m[343];
c[6] = m[351];
c[8] = c[7] = (char)(((0x38|m[1])<<1)&~0x80);
i(1,atoi(argv[1]),&x);
return 0;
}