Skip to content

Instantly share code, notes, and snippets.

@pi8027
Last active August 29, 2015 13:56
Show Gist options
  • Save pi8027/9035164 to your computer and use it in GitHub Desktop.
Save pi8027/9035164 to your computer and use it in GitHub Desktop.
char a[]="!!!!!!!!!!!!!!!Zi!sf!wc!z^![!!\"X!!!!o2*-!?+q0+-!>,q0+,!?-p0+,!?-p0+,!?-p0+,2$!--p0+,0&!--p0+,-##'!--p0+,,*!--p0*/&$#+.#.#@#4#@-,#e0+>-.$7-6,@,6R0-<+0$8.7)@)7T0/:)2$:.6(?'##7U018'4$<.6&@&6X0+>%6$>%#$#'6$@$6$#'#Q0+,++%,.,*-$/(,$,+-$,(.R0+,++%,.,*-$0',$,+-$,&0R0+,++%,.,*-$2%,$,+-$,$2R0+,++%,.,*-$4#,$,+-$>R0+,++%,.?$?$,+-$+#*#+R0+,++%,.,#4$,+,$,+-$)##,+R0+,++%,.,%2$,+,$,+-$'0+R0+,++%,.,(/$,+,$,+-$%##0+R0+,++%,--*-$,+,$,*.$#3,R0,+++%+/7,6/5##1##7Q0.)++%*27,6/5##/6T00'++%'77-5/5-6V11%++%&:7,6/5##'6x#++%$>7,7.5%6!!!!!!!!!!!!!!!l";i,j,o,m;main(){for(;a[i];i++){for(j=0;(a[i]+158)%96-j;j++)o++,putchar("@1"[m]),o%246||putchar('\n');(a[i]-33)&&(m=!m);}exit(1);}
#define OPENP (
#define CLOSEP )
#define OPENB {
#define CLOSEB }
#define SEMICOLON ;
n,m SEMICOLON
main OPENP CLOSEP OPENB
scanf OPENP "%d",&n CLOSEP SEMICOLON
while OPENP n-- CLOSEP OPENB
scanf OPENP "%d",&m CLOSEP SEMICOLON
printf OPENP "%lld\n", OPENP long long CLOSEP OPENP m+1 CLOSEP * OPENP OPENP long long CLOSEP m CLOSEP /2 CLOSEP SEMICOLON
CLOSEB
return 0 SEMICOLON
CLOSEB
main(){exit(!puts("Threads 2k14"));}
#include<stdio.h>
#include<stdlib.h>
typedef long long prime_t;
prime_t m;
int palindrome(prime_t n){
int a[15], i = 0, j = 0;
for(; n != 0; i++){
a[i] = n%10;
n = n/10;
}
for(; j != i; j++){
if(a[j] != a[i-j-1]) return 0;
}
return 1;
}
prime_t modexp(prime_t b, int e, prime_t m){
prime_t r = 1;
while(e){
if(e&1) r = b*r%m;
e >>= 1;
b = b*b%m;
}
return r;
}
int mr(prime_t n, int k){
prime_t s = 0;
int d = n-1, i = 0, j;
while(!(d%2)) s++, d = d/2;
for(; i != k; i++){
prime_t a = 2+rand()%(n-3);
prime_t x = modexp(a, d, n);
if(x != 1 && x != n-1){
for(j = 1; j != s; j++){
x = (x*x)%n;
if(x == 1) return 0;
if(x == n-1) goto LOOP;
}
return 0;
}
LOOP:
continue;
}
return 1;
}
void pprimes(prime_t b, prime_t e){
prime_t p = b;
for(; p <= e; p+=2){
if((m = p, palindrome(p)) && mr(p, 3))
printf("%lld\n", p);
}
}
int main(){
puts("2\n3");
pprimes(5, 929);
pprimes(10301, 98689);
pprimes(1003001, 1998991);
pprimes(3001003, 3998993);
pprimes(7014107, 7996997);
pprimes(9002009, 9989899);
pprimes(100030001, 199999991);
pprimes(300020003, 399878993);
pprimes(700020007, 799959997);
pprimes(900010009, 999727999);
exit(0);
}
a[99];n;main(){for(scanf("%d",&n),read(open(__FILE__,0),a,76);n--;)puts(a);}
__,___,_____;
____(){
(scanf("%c",&__) < ' '-' ') ||
((__=='*'-' '
?((_____?puts(___%('#'-' ')?"N":"Y"):(_____=('!'-' '))),___-=___)
:(___=(__==(' '+' '+'!')?"!#!!$"[___]-' ':"$\"$#$"[___]-' '))),
____());
}
main(){
__=__<____();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment