Search found 5 matches

by tatter
Sun Oct 13, 2002 5:36 am
Forum: Volume 1 (100-199)
Topic: 106 - Fermat vs. Pythagoras
Replies: 138
Views: 30700

reply

funny, ur method seems so familiar to mine esp after u read my message for help... :D

anyway, no one replied to my post (all my own posts :( ), but i posted in my message one way to do it using dynamic programming, u may like to refer to it.
by tatter
Sun Oct 13, 2002 5:28 am
Forum: Volume 1 (100-199)
Topic: 106 - Fermat vs. Pythagoras
Replies: 138
Views: 30700

dynamic

the idea is to make the loop dependent on z instead of x or y
where x^2 + y^2 = z^2
since we know z>x and z>y, using this info we can be sure we can build our result based upon a previous result of z

let's do some calculations:

x^2 + y^2 = z^2

letting x = z - a, y = z - b

(z - a)^2 + (z - b)^2 ...
by tatter
Mon Sep 30, 2002 11:35 am
Forum: Volume 1 (100-199)
Topic: 106 - Fermat vs. Pythagoras
Replies: 138
Views: 30700

idea?

i was thinking...
what if i instead of iterating through all possible numbers from 0 to N, i generate a list of numbers to go through. this list of number would have all the multiples of the previously generated triples struck out as we know these are confirmed cases. that would have leave us a ...
by tatter
Mon Sep 30, 2002 10:16 am
Forum: Volume 1 (100-199)
Topic: 106 - Fermat vs. Pythagoras
Replies: 138
Views: 30700

The code

[cpp]#include <cstdio>
#include <iostream>
using namespace std;

#define MAX_NUMBER 1000000

unsigned int* v;

int gcd(int i, int j) {
while (i!=j)
if (i<j) j=j-i;
else i=i-j;
return i;
}

bool checkprime(unsigned int i,unsigned int j,unsigned int k) {
if (gcd(i, j) == 1)
if (gcd(i, k) == 1 ...
by tatter
Mon Sep 30, 2002 9:52 am
Forum: Volume 1 (100-199)
Topic: 106 - Fermat vs. Pythagoras
Replies: 138
Views: 30700

106 : How to make it faster?

Currently I am working on problem 106 and using the following method:

x^2 = z^2 - y^2
x^2 = (z + y)(z - y)
let a = z + y
if x^2 is divisible by a,
x^2 = ab
where b is the other root
also since
(z + y) - (z - y) = 2y
(z + y) + (z - y) = 2z

therefore if
a + b is divisible by 2
then we can get z ...

Go to advanced search