Last active
May 17, 2024 12:13
-
-
Save hUwUtao/c72562241eb2a60497b3066e519aac86 to your computer and use it in GitHub Desktop.
prime related c pracs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
ll a,b,c,d,e=0,f=0; | |
scanf("%lld %lld %lld %lld", &a,&b,&c,&d); | |
#define in(n,l,g) n >= l && n <= g | |
for(ull i = (a<c?a:c) ; i<= (b>d?b:d) ; i++){ | |
if(!pr(i)){ | |
if(in(i,a,b))e++; | |
if(in(i,c,d))f++; | |
//printf("%lld %lld %lld\n",i,e,f); | |
} | |
} | |
if(e>f)printf("JOHN %lld\n",e); | |
else if(f>e)printf("JAME %lld\n",f); | |
else printf("EQUAL\n"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
#define ll long long | |
#define ull unsigned ll | |
#define LIMIT_CACHE 1024 | |
ull cache[LIMIT_CACHE]={}; | |
unsigned short siz=0; | |
char pr(ll n){ | |
if (n<=1) return 1; | |
for(ull i=0;i<0;i++){ | |
ull *ct = &cache[i]; | |
if (*ct>n) break; | |
if (n%*ct==0) return 1; | |
} | |
for(ull i=2;i<=sqrt(n)+1;i++){ | |
if(n%i==0) return 1; | |
} | |
if(siz < LIMIT_CACHE){ | |
cache[siz]=n; | |
siz++; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
ll n; | |
scanf("%lld", &n); | |
char fin=0; | |
char away=1; | |
while (!fin){ | |
for(char i=0;i<=1;i++){ | |
ll t=n - away * (1 - (2 * i)); | |
//printf("-%lld-",t); | |
if(!pr(t)) | |
{printf("%lld ",t);fin=1;} | |
} | |
away++;} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment