Differences From Artifact [6328445c69b877f6]:
- File
lib/geo/pythagoras.cpp
- 2013-12-05 00:28:44 - part of checkin [64a27e41ea] on branch trunk - Pythagoras generator (user: kinaba) [annotate]
To Artifact [395c6eb448780702]:
- File
lib/geo/pythagoras.cpp
- 2013-12-05 00:29:40 - part of checkin [4c3be66099] on branch trunk - Comment (user: kinaba) [annotate]
> 1
> 2 //-------------------------------------------------------------
1 // Enumerate coprime pythagoras triangles 3 // Enumerate coprime pythagoras triangles
> 4 //
> 5 // Verified by
> 6 // - SRM 599 Div1 LV2
> 7 //-------------------------------------------------------------
> 8
2 9
3 for(int m=1;; ++m) 10 for(int m=1;; ++m)
4 for(int n=1; n<m; ++n) if(((m^n)&1) && gcd(m,n)==1) 11 for(int n=1; n<m; ++n) if(((m^n)&1) && gcd(m,n)==1)
5 { 12 {
6 int a = m*m-n*n, b = 2*m*n, c = m*m+n*n; 13 int a = m*m-n*n, b = 2*m*n, c = m*m+n*n;
7 if(a>b) swap(a,b); 14 if(a>b) swap(a,b);
8 } 15 }