Source code for submission s641

fl.cpp

  1. #include <stdio.h>
  2. #include <set>
  3.  
  4. using namespace std;
  5.  
  6. void solve(int n){
  7. set<int> checked;
  8.  
  9. int p = 0, y = n + 1, max = 2000000000;
  10. bool first = true;
  11.  
  12. while(y < max){
  13. //printf("y %d\n", y);
  14. //printf("max %d\n", max);
  15.  
  16. if(checked.count(y)){
  17. y++;
  18. continue;
  19. }
  20. double d = (double)n * y / (y - n);
  21. int x = (int)d;
  22. checked.insert(x);
  23.  
  24. if(x == d){
  25. if(first){
  26. max = x;
  27. first = false;
  28. }
  29.  
  30. p++;
  31. }
  32.  
  33. y++;
  34. }
  35.  
  36. printf("%d\n", p);
  37. }
  38.  
  39. int main(){
  40. int a, n;
  41. char c;
  42.  
  43. while(scanf("%d%c%d ", &a, &c, &n) == 3){
  44. solve(n);
  45. }
  46. }
  47.