-
-
Save Toru3/d6ab30772d916a7476ac7c23da906f8a to your computer and use it in GitHub Desktop.
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 <stdbool.h> | |
#define N 100 | |
#define M 5 | |
bool check(long x[]){ | |
long sum=0; | |
for(long i=0; i<M; i++){ | |
sum += x[i]; | |
} | |
for(long i=0; i<M; i++){ | |
for(long j=0; j<i; j++){ | |
if(x[j]*x[i]%sum!=0){ | |
return false; | |
} | |
} | |
} | |
return true; | |
} | |
int main(void){ | |
long x[M]; | |
for(long e=5; e<=N; e++){ | |
x[4]=e; | |
for(long d=4; d<e; d++){ | |
x[3]=d; | |
for(long c=3; c<d; c++){ | |
x[2]=c; | |
for(long b=2; b<c; b++){ | |
x[1]=b; | |
for(long a=1; a<b; a++){ | |
x[0]=a; | |
if(check(x)){ | |
for(long i=0; i<M; i++){ | |
printf("%ld ", x[i]); | |
} | |
printf("\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 <stdlib.h> | |
#include <stdbool.h> | |
inline int ctz(long x){ | |
// GCCの組み込み関数 | |
return __builtin_ctzl(x); | |
} | |
inline int min(int a, int b){ | |
return a<b ? a : b; | |
} | |
inline int max(int a, int b){ | |
return a>b ? a : b; | |
} | |
long gcd(long a, long b){ | |
if(a==0) return b; | |
if(b==0) return a; | |
a = labs(a); | |
b = labs(b); | |
int ta = ctz(a); | |
int tb = ctz(b); | |
int shift = min(ta,tb); | |
a >>= ta; | |
b >>= tb; | |
if(a<b){ | |
long t=a; | |
a=b; | |
b=t; | |
} | |
do{ | |
a-=b; | |
a >>= ctz(a); | |
if(a<b){ | |
long t=a; | |
a=b; | |
b=t; | |
} | |
}while(b!=0); | |
return a << shift; | |
} | |
#define N 100 | |
int main(void){ | |
for(long e=5; e<=N; e++){ | |
long g1 = e; | |
long s1 = e; | |
for(long d=4; d<e; d++){ | |
long g2 = gcd(d,g1); | |
long f1 = e*d; | |
long s2 = s1 + d; | |
if(f1<max(15, s2))continue; | |
for(long c=3; c<d; c++){ | |
long g3 = gcd(c, g2); | |
long f2 = gcd(c*g2, f1); | |
long s3 = s2 + c; | |
if(f2<max(15, s3))continue; | |
for(long b=2; b<c; b++){ | |
long g4 = gcd(b,g3); | |
long f3 = gcd(b*g3, f2); | |
long s4 = s3 + b; | |
if(f3<max(15, s4))continue; | |
for(long a=1; a<b; a++){ | |
long f4 = gcd(a*g4, f3); | |
long s5 = s4 + a; | |
if(f4%s5==0){ | |
printf("%ld %ld %ld %ld %ld\n", a, b, c, d, e); | |
} | |
} | |
} | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment