4c3be66099 2013-12-05 kinaba: 4c3be66099 2013-12-05 kinaba: //------------------------------------------------------------- 64a27e41ea 2013-12-05 kinaba: // Enumerate coprime pythagoras triangles 4c3be66099 2013-12-05 kinaba: // 4c3be66099 2013-12-05 kinaba: // Verified by 4c3be66099 2013-12-05 kinaba: // - SRM 599 Div1 LV2 4c3be66099 2013-12-05 kinaba: //------------------------------------------------------------- 4c3be66099 2013-12-05 kinaba: 64a27e41ea 2013-12-05 kinaba: 64a27e41ea 2013-12-05 kinaba: for(int m=1;; ++m) 64a27e41ea 2013-12-05 kinaba: for(int n=1; n<m; ++n) if(((m^n)&1) && gcd(m,n)==1) 64a27e41ea 2013-12-05 kinaba: { 64a27e41ea 2013-12-05 kinaba: int a = m*m-n*n, b = 2*m*n, c = m*m+n*n; 64a27e41ea 2013-12-05 kinaba: if(a>b) swap(a,b); 64a27e41ea 2013-12-05 kinaba: }