| ||||
#include <stdio.h> int main(){ const unsigned limit = 19580000, module = 2147483647, add = 1234567890; putchar('0'); int not3[33] = {1814225, 2302521, 5802141, 6018533, 6748043, 7376999, 8331290, 8384746, 8684370, 8906903, 9351610, 10514663, 10537445, 10833849, 11729324, 11817292, 11938310, 12241472, 14747269, 15942195,16697130, 16760699,16921012, 17223857, 17396747, 18525295, 18803409, 19178068, 19410255, 19431851, 19517128, limit}; unsigned m = 1, t, a, at, s, k; unsigned i, left = 2, right = not3[0], c = 1; do{ for(i = left; i < right; i++){ m += add; m &= module; if(m % 3 == 0 || m % 5 == 0 || m % 7 == 0 || m % 11 == 0 || m % 13 == 0 || m % 17 == 0 || m % 19 == 0 || m % 23 == 0 || m % 29 == 0 || m % 31 == 0 || m % 37 == 0 || m % 43 == 0){putchar('0'); goto cont;} t = m - 1; s = 0; while( !(t & 1)){t >>= 1; s++;} k = t, at = 1, a = 3; while(k){ if( (k & 1)){k--; asm volatile("mull %%ebx\n\t divl %%ecx":"=d"(at):"a"(at),"b"(a),"c"(m));} else{k >>= 1; asm volatile("mull %%eax\n\t divl %%ebx":"=d"(a):"a"(a),"b"(m));} } if( at == 1 || at == m - 1){ putchar('1'); goto cont; } else{ k = 1; while( k < s){ k++; asm volatile("mull %%eax\n\t divl %%ebx":"=d"(at):"a"(at),"b"(m)); if(at == m - 1){ putchar('1'); goto cont;} } } putchar('0'); cont: k = 0; } putchar('0'); m += add; m &= module; left = not3[c - 1] + 1; right = not3[c]; c++; }while(c <= 33); return 0; } |
||||
|