标签:
因为x要最小,从最小的j-i开始枚举
1 #include <cstdio> 2 #include <cmath> 3 4 int main() { 5 int t, n, j; 6 scanf("%d", &t); 7 while (t--) { 8 int ans = -1; 9 scanf("%d", &n); 10 for (int i = sqrt(n); i >= 1; i--) { 11 if (n % i == 0 && n != i*i) { 12 j = n / i; 13 if ((j-i)%2==0) { 14 ans = (j-i)/2; 15 break; 16 } 17 } 18 } 19 printf("%d\n", ans); 20 } 21 return 0; 22 }
标签:
原文地址:http://www.cnblogs.com/chbeater/p/4437817.html