Arithmetic ProgressionsEquality Series
Description
An Equality series is a series that can be expressed as a, a + B, a + 2b,..., a + nb (n =.
In this case, a is a non-negative integer and B is a positive integer. Write a program to find the series of equal differences whose length is n in the number of pairs in the Set S. A set of two-digit numbers is a set of all numbers that can be expressed as p ^ 2 + q ^ 2.
Format
TIME LIMIT: 5 seconds
PROGRAM NAME: Ariprog
INPUT FORMAT:
(File ariprog. in)
The first line: N (3 <= N <= 25), the length of the arithmetic difference sequence to be searched.
Row 2: M (1 <= M <= 250), search for the upper limit of the number of dual partitions 0 <= p, q <= M.
OUTPUT FORMAT:
(File ariprog. out)
If no sequence is found, 'none' is output '.
If one or more rows are output, each row is composed of two integers: a and B.
These rows should be sorted by B and then by.
There will be no more than 10,000 arithmetic differences.
SAMPLE INPUT
5
7
SAMPLE OUTPUT
1 4
37 4
2 8
29 8
1 12
5 12
13 12
17 12
5 20
2 24
The time limit is quite broad...
View my evaluation results (basically violent ....)
Compiling...
Compile: OK
Executing...
Test 1: test OK [0.000 secs, 664 KB]
Test 2: test OK [0.000 secs, 664 KB]
Test 3: test OK [0.000 secs, 664 KB]
Test 4: test OK [0.000 secs, 664 KB]
Test 5: test OK [0.027 secs, 664 KB]
Test 6: test OK [0.189 secs, 664 KB]
Test 7: test OK [2.025 secs, 664 KB]
Test 8: test OK [4.590 secs, 664 KB]
Test 9: test OK [4.212 secs, 664 KB]
All tests OK.
Your program ('ariprog') produced all correct answers! This is your submission #2 for this problem. Congratulations!
The eighth point is quite thrilling...
Someone may have seen that I submitted it for the second time ....
The error is that I did not review the problem, and ignored the unsolvable situation. The third point is the tragedy...
Here is my idea for doing this:
First, enumerate p and q, and mark all possible double-digit numbers,
Enumerate a and B respectively, and then use the above mark to judge,
Do not match jump out immediately.
That's it.
{ID: codeway3PROG: ariprogLANG: PASCAL}program ariprog; var i,j,n,m,max,k,l,b:longint; a:array[0..200000]of integer; begin assign(input,'ariprog.in'); reset(input); assign(output,'ariprog.out'); rewrite(output); readln(n); n:=n-1; b:=0; readln(m); for i:=0 to m do for j:=0 to m do begin a[i*i+j*j]:=1; if i*i+j*j>max then max:=i*i+j*j; end; for i:=1 to max do for j:=0 to max-n*i do begin if (a[j]=1)and(a[j+n*i]=1) then begin l:=0; for k:=1 to n-1 do if a[j+k*i]=0 then begin l:=1; break; end; if l=0 then begin b:=1;writeln(j,' ',i);end; end; end; if b=0 then writeln('NONE'); close(input); close(output); end.