Bs first. You can create a table before submitting this question.
At the beginning, there was a problem with binary writing. I first found n and then m. In fact, we need to first find m and then find n.
Another solution is to solve the equation and solve the Pell Equation.
You must first find the expression for both brute force and equation solving. N * (n + 1)/2 = x * (x + 1)/2-n * (n + 1) + n; n * n/2 = x * x + x. Then it is transformed into a standard Pel equation, and then solved by recursion.
The following is the binary code:
#include<iostream>#include<cstdio>using namespace std;const int n=~(unsigned int)0/2;int main(){ int t=0; for(long long i=6;i<n&&t<=10;i++) { long long min=1; long long max=i+1; long long mid; while(min<=max) { mid=(min+max)/2; if(mid*mid*2==i*(i+1)) { printf("%10lld%10lld\n",mid,i); t++; break; } else if(mid*mid*2>i*(i+1)) max=mid-1; else min=mid+1; } } return 0;}
It takes about 3 minutes to obtain 10 groups of solutions. .....
The code for solving the equation is as follows:
#include<iostream>#include<cstdio>using namespace std;int main(){ int x3,y3; for(int x1=1,y1=1,x2=1,y2=1,t=0;t<10;t++) { x3=(2*x1+1)*(2*x2+1)+8*y1*y2; y3=(2*x1+1)*y2+y1*(2*x2+1); printf("%10d%10d\n",y3,(x3-1)/2); x2=(x3-1)/2; y2=y3; } return 0;}