|
|
вернуться в форумCould anyone check my program?? #include<iostream.h> long N, p, a; void main() { cin>>N; //p^2 + p*(2*a-1) - 2*N = 0 p = a = -1; // not a valid one long i = 2, m1, m2; while (i*i <= 2*N) { if ( 2*N % i == 0) { m1 = i; m2 = 2*N / i; if ( (m2 - m1 +1)%2==0 ) if (m1 > p) { a = (m2 - m1 +1)/ 2; p = m1; } } i++; } cout<<a<<" "<<p; } Re: Could anyone check my program?? Ready. Jejeje....little detail that i don't take in care... |
|
|