Source code for submission s588

fl.cpp

  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdio>
  4. #include <cmath>
  5. #include <set>
  6. #include <map>
  7. #include <string>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. //printf("%d\n", 1<<30);
  14. int n;
  15. char s[100000];
  16. while(scanf("%s", s) == 1)
  17. {
  18. //printf("%s\n", s);
  19. char *t = s+2;
  20. //printf("%s\n", t);
  21. sscanf(t, "%d", &n);
  22. //printf("%d\n", n);
  23.  
  24. int x, y;
  25. int count = 0;
  26. for(x=n+1; x*x <= n*2*x; x++)
  27. {
  28. /*for(y=x; ; y++)
  29. {
  30. if(x*y == n*(x+y))
  31. {
  32. count++;
  33. break;
  34. }
  35. else if(x*y > n*(x+y))
  36. {
  37. break;
  38. }
  39. }*/
  40. y = n*x/(x-n);
  41. if(x <= y && x*y == n*(x+y))
  42. count++;
  43. }
  44. printf("%d\n", count);
  45. }
  46.  
  47. return 0;
  48. }
  49.