Figure 1
Figure 2
単位正方形の四つすべての頂点から有理距離となるような座標平面上の点が存在するかどうかは知られていない。ただし、そのような点がもとの正方形の辺上に存在しないことは既知である。
Figure 2
#include <stdio.h>
#include <stdlib.h>
long gcdl(long a, long b){
if(a == 0)return labs(b);
if(b == 0)return labs(a);
a = labs(a);
b = labs(b);
int az = __builtin_ctzl(a);
int bz = __builtin_ctzl(b);
int shift = az < bz ? az : bz;
b >>= bz;
while (a != 0){
a >>= az;
long diff = b - a;
az = __builtin_ctzl(labs(diff));
b = a < b ? a : b;
a = labs(diff);
}
return b << shift;
}
#include
#include <time.h>
#include <gmp.h>
#include <stdlib.h>
long gcdl(long a, long b){
if(a == 0)return labs(b);
if(b == 0)return labs(a);
a = labs(a);
b = labs(b);
int az = __builtin_ctzl(a);
int bz = __builtin_ctzl(b);
int shift = az < bz ? az : bz;
b >>= bz;
while (a != 0){
a >>= az;
long diff = b - a;
az = __builtin_ctzl(labs(diff));
b = a < b ? a : b;
a = labs(diff);
}
return b << shift;
}
int main(int argc, char const *argv[])
{
long cpu_time;
double sec;
mpz_t am;
mpz_t bm;
mpz_t apm;
mpz_t bpm;
mpz_t nm;
mpz_t mm;
mpz_t km;
mpz_t lm;
mpz_inits(am,bm,apm,bpm,nm,mm,km,lm,NULL);
long N;
long N4;
long N2;
long a;
unsigned long au;
long b;
unsigned long bu;
long p;
long ap;
unsigned long apu;
long bp;
unsigned long bpu;
char flag;
long gcd;
N = 10000;
N4 = N / 4;
N2 = N / 2;
for (p = 1; p < N4; p++){
for(a = (long)-p/2; a < N4; a++){
if(a != 0){
gcd = gcdl(a,p);
ap = a + p;
au = 4 * labs(a); //a = 4 * a'
apu = 4 * labs(ap); //a+p = 4(a'+p')
mpz_ui_pow_ui(am,au,2UL); //am = a^2
mpz_ui_pow_ui(apm,apu,2UL); //apm = (a+p)^2
for (b = -p; b <= N2; b++){
if(b != 0){
bu = 1 + 2 * b; // b = 1+2b'
if(gcdl(gcd,bu) == 1){
flag = 0;
bp = bu + 4 * p; //b+p = b + 4*p'
bu = labs(bu);
bpu = labs(bp);
mpz_ui_pow_ui(bm,bu,2UL); //bm = b^2
mpz_ui_pow_ui(bpm,bpu,2UL); //bpm = (b+p)^2
mpz_add(nm,am,bm);
mpz_add(mm,apm,bm);
mpz_add(km,am,bpm);
mpz_add(lm,apm,bpm);
if(mpz_perfect_square_p(nm)){
flag++;
}
if(mpz_perfect_square_p(mm)){
flag++;
}
if(mpz_perfect_square_p(km)){
flag++;
}
if(mpz_perfect_square_p(lm)){
flag++;
}
if(flag > 2){
fprintf(stderr,"\ra:%d b:%d p:%d flag:%d\n",4*a,1+2*b,4*p,flag);
}
}
}
}
}
}
fprintf(stderr,"\r[%d]",p);
}
mpz_clears(am,bm,apm,bpm,nm,mm,km,lm,NULL);
cpu_time = clock();
sec = (double)cpu_time / CLOCKS_PER_SEC;
fprintf(stderr,"%lf sec\n", sec);
return 0;
}
a:28 b:21 p:44 flag:3
a:-24 b:-7 p:52 flag:3
a:104 b:153 p:100 flag:3
a:20 b:-49 p:148 flag:3
a:52 b:-63 p:228 flag:3
a:-80 b:39 p:276 flag:3
a:360 b:-105 p:424 flag:3
a:272 b:615 p:456 flag:3
a:1840 b:897 p:456 flag:3
a:44 b:-117 p:600 flag:3
a:828 b:7429 p:600 flag:3
a:-304 b:-297 p:700 flag:3
a:-168 b:-315 p:740 flag:3
a:752 b:2145 p:816 flag:3
a:364 b:4725 p:836 flag:3
a:400 b:-279 p:840 flag:3
a:4140 b:437 p:876 flag:3
a:8008 b:5425 p:920 flag:3
a:-476 b:-231 p:996 flag:3
a:364 b:627 p:1200 flag:3
a:680 b:153 p:1212 flag:3
a:2576 b:345 p:1384 flag:3
a:828 b:7429 p:1452 flag:3
a:-408 b:931 p:1500 flag:3
a:112 b:1575 p:1560 flag:3
a:1960 b:441 p:1560 flag:3
a:-276 b:115 p:1596 flag:3
a:196 b:315 p:1628 flag:3
a:924 b:-385 p:2028 flag:3
a:448 b:975 p:2280 flag:3
a:-472 b:3465 p:2320 flag:3
a:164 b:-123 p:2356 flag:3
a:600 b:-481 p:2436 flag:3
a:476 b:711 p:2604 flag:3
a:3360 b:217 p:2888 flag:3
a:-644 b:483 p:3000 flag:3
a:-396 b:403 p:3000 flag:3
a:520 b:231 p:3288 flag:3
a:-900 b:-945 p:3364 flag:3
a:2604 b:-1085 p:3380 flag:3
a:-1664 b:427 p:3500 flag:3
a:-496 b:1953 p:3576 flag:3
a:1672 b:1995 p:3660 flag:3
a:4464 b:527 p:3696 flag:3
a:-1340 b:4389 p:4380 flag:3
a:-1716 b:1463 p:4500 flag:3
a:-368 b:465 p:4680 flag:3
a:-88 b:1935 p:4732 flag:3
a:6232 b:-713 p:4808 flag:3
a:9240 b:-805 p:4836 flag:3
a:-2444 b:2511 p:5244 flag:3
a:-2340 b:1349 p:5476 flag:3
a:-588 b:1715 p:5476 flag:3
a:2772 b:-2679 p:5500 flag:3
a:76 b:-1443 p:6000 flag:3
a:3848 b:-1335 p:6120 flag:3
a:1596 b:2275 p:6204 flag:3
a:-3080 b:-711 p:6240 flag:3
a:92 b:525 p:6460 flag:3
a:1512 b:55 p:6920 flag:3
a:2108 b:9269 p:7000 flag:3
a:-2924 b:-693 p:7800 flag:3
a:5016 b:1313 p:8092 flag:3
a:-2964 b:5723 p:8200 flag:3
a:-164 b:-1677 p:8400 flag:3
a:4200 b:-3367 p:8772 flag:3
a:6396 b:-3655 p:9108 flag:3
[2499]4579.421000 sec
おりゃぁぁぁ!
pic.twitter.com/FHOttUPTIw
— Y.K. (@eyV6a3AdWcAoZhY) December 5, 2023