An array of hooks and its application uva106

Source: Internet
Author: User
Tags gcd

Tick array

If the ternary group (A,B,C) satisfies a^2 + b^2 = C^2 's tick array, is there an infinite number of tick arrays?

The answer is yes, multiply the triples by D, you can get the new triples (DA,DB,DC) (DA) ^2 + (db) ^2 = (DC) ^2--(a^2+b^2) * d^2 =c^2 * d^2

The value of D is arbitrary, so there are multiple tick arrays

An array of origin hooks and strands

The source tick array is a ternary group (A,B,C), where a,b,c only exists common factor 1 and satisfies a^2 + b^2 = c^2

Accumulating data: Some of the following source tick arrays

(3,4,5), (5,12,13), (8,15,17), (7,24,25)

(20,21,29), (9,40,41), (12,35,37), (11,60,61)

Analyze data:

It can be inferred from these data that there may be a conclusion that the parity of a, B is different, and that C is always odd

Proof: If A and B are even, then C is definitely an even number, then there is a common factor of 2, so the ternary group is not the origin of the A,b,c

If A and B are odd, then C is necessarily an even number. Set a=2*x+1, B=2*y+1,c=2*z bring it into a^2 + b^2 = c^2

Get (2x+1) ^2 + (2y+1) ^2 = (2z) ^2--4x^2+4x+4y^2+4y+2=4z^2

The left side of the equation is an odd number and the right is an even number, so the above hypothesis is not true

 So a, B is an even number, an odd number, and C is an odd number.

  

How to quickly get a certain range of source tick array

(A,B,C) is the source hook array, and A is odd, B is even, C is odd, then can be factorization,

a^2 = c^2-b^2 = (c-b) (c+b)

3^2 = (5-4) (5+4) = 1 * 9

15^2 = (17-8) (17+8) = 9 * 25

32^2 = (37-12) (37+12) = 25 * 49

As if C-b and c+b always squared,

Proof: Hypothesis (c-b)%d==0 && (c+b)%d==0, then according to the nature of the mold, there is (c+b) + (c-b) = 2c, 2c%d==0, and (c+b)-(c-b) =2b,2b%d==0,

That is, D is divisible by 2b and 2c, because B and C do not have common factor, so d can only be 1 or 2, by (C+b) (C-b) =a^2 is also a multiple of D, and a is odd, so a^2 is odd, so d can only take value 1

So (C-b) and (C+b), and (C-b) (c+b) =a^2, namely (C-b) and (C+b) and is the sum of squares, This situation only occurs when (C-b) and (C+B) itself is the sum of squares

Set c+b=s^2,c-b=t^2, where s>t>=1 was no common factor of odd

To solve the equation

uva106 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&itemid=8&page=show_problem& category=115&problem=42&mosmsg=submission+received+with+id+15454112

Give us a certain n, want us to ask how many 1->n within the source hook array, and how many do not belong to the hook array of numbers

1#include <stdio.h>2#include <string.h>3#include <stdlib.h>4#include <algorithm>5#include <iostream>6#include <queue>7#include <stack>8#include <vector>9#include <map>Ten#include <Set> One#include <string> A#include <math.h> - using namespacestd; - #pragmaWarning (disable:4996) thetypedefLong LongLL;  - Const intINF =1<< -; - /* -  + */ - BOOLvis[1000000+Ten]; + intans1[1000000+Ten]; A intgcdintAintb) at { -     if(b = =0) -         returnA; -     returnGCD (b, a%b); - } - intMain () in { -     intS, T, A, B, C; to     intCNT =0, N; +      while(SCANF ("%d", &n)! =EOF) -     { theCNT =0; *memset (ANS1,0,sizeof(ans1)); $memset (Vis,0,sizeof(Vis));Panax Notoginseng         intm = sqrt (2*n); -          for(s =3; S <= m; s + =2) the         { +              for(t =1; T < S; T + =2) A             { the                 if(GCD (S, t)! =1)Continue; +A = S *T; -b = (s*s-t*t)/2; $c = (s*s + t*t)/2; $                 if(c>n) Break; -                 if(ll) A*a + (ll) B*b = = (LL) c*c) -                 { the                     //printf ("%d%d%d\n", A, B, c); -ans1[c]++;Wuyi                      for(inti = a, J = b, k = c; K <= N; i + = A, J + = B, k + =c) theVis[i] = vis[j] = Vis[k] =true; -                 } Wu                 Else if(ll) A*a + (LL) B*b < (LL) c*c) -                      Break; About             } $         } -  -          for(inti =1; I <= N; ++i) -         { AAns1[i] + = ans1[i-1]; +             if(!Vis[i]) thecnt++; -         } $printf"%d%d\n", Ans1[n], CNT); the     } the     return 0; the}
View Code

An array of hooks and its application uva106

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.