fork download
  1. // main.cpp
  2. // CNPIIM
  3. //
  4. // Created by Carl Jalal on 4/11/14.
  5. // Copyright (c) 2014 Carl Jalal. All rights reserved.
  6. //
  7.  
  8. #include <stdio.h>
  9. #include <cmath>
  10.  
  11. int main()
  12. {
  13. long answer,T,N,a,d,b,L1,amount;
  14. long n;
  15. float L2;
  16.  
  17. scanf("%ld",&T);
  18. while (T--) {
  19. scanf("%ld",&N);
  20.  
  21. amount = 0;
  22. answer = 0;
  23. n=N-N%2;
  24. for (a = 1; a <= n/2; a++) {
  25. d = N-a;
  26. L1 = a*d;
  27. //L2 = sqrt((float)L1);
  28.  
  29.  
  30. for (b = 1; b*b < L1 ; b++) {
  31. //printf("%ld %f\n",b,L2);
  32. amount = 2*(((L1-1)/b) - b + 1) - 1;
  33. if (d==a) answer+=amount;
  34. else answer+=2*amount;
  35.  
  36. }
  37.  
  38. }
  39.  
  40. printf("%ld\n",answer);
  41. }
  42. }
Success #stdin #stdout 0.13s 3300KB
stdin
5
2400
2425
2450
2475
2500
stdout
-1978901337
-907152770
188464060
1308198172
-1842629629