почему WA 9 ? помогите
#include <iostream>
#include <math.h>
using namespace std;
long long i, n, d;
double a;
int p;
int main(){
cin >> n;
n *= 2;
p =(int) sqrt(n + 0.0);
while(1){
a = (n - p * p + p + 0.0) / (2 * p);
if(0 < a && a == (int) a && (p * p + 2 * a * p - p) == n)
break;
p --;
}
cout << (int)a << ' ' << p;
}