Source code for submission s944

Go to diff to previous submission

fl.cpp

  1. #include <stdio.h>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. int n;
  9. while(scanf("1/%d\n", &n) == 1) {
  10. int x = n;
  11. float y;
  12. int posibilities = 0;
  13.  
  14. do {
  15. x++;
  16. y = (float)(n * x) / (x - n);
  17.  
  18. //if((1.0f/x) + (1.0f/y) == (1.0f/n)) {
  19. if(y == (int)y) {
  20. posibilities++;
  21. }
  22. }
  23. while(x < y);
  24.  
  25. printf("%d\n", posibilities);
  26.  
  27. }
  28.  
  29. }
  30.  

Diff to submission s883

fl.cpp

--- c5.s883.cteam074.fl.cpp.0.fl.cpp
+++ c5.s944.cteam074.fl.cpp.0.fl.cpp
@@ -4,52 +4,23 @@
 using namespace std;
 
-struct Cislo {
-        int x, y;
-        Cislo(){}
-        Cislo(int x, int y) { this->x = x; this->y = y; }
-};
-
 int main() {
         
         int n;
         while(scanf("1/%d\n", &n) == 1) {
-                int x, y;
-                x = n;
-                //printf("n = %d\n", n);
+                int x = n;
+                float y;
                 int posibilities = 0;
-                int max;
-                
-                vector<Cislo> cisla;
                 
                 do {
                         x++;
-                        y = (n * x) / (x - n);
-                        max = n * 2;
-                        //printf("x = %d, y = %d", x, y);
+                        y = (float)(n * x) / (x - n);
                         
-                        if((1.0f/x) + (1.0f/y) == (1.0f/n)) {
-                                //bool exists = false;
-                                /*for(int i = 0; i < cisla.size(); i++) {
-                                        if(x == cisla[i].x || x == cisla[i].y) {
-                                                exists = true;
-                                                break;
-                                        }
-                                }               */                      
-                                /*if(!exists) {
-                                        if(x < y)
-                                                cisla.push_back(Cislo(x, y));
-                                        else
-                                                cisla.push_back(Cislo(y, x));
-                                        posibilities++;
-                                        //printf("x = %d, y = %d\n", x, y);
-                                }*/
-                                
-                                
-                                cisla.push_back(Cislo(x, y));
+                        //if((1.0f/x) + (1.0f/y) == (1.0f/n)) {
+                        if(y == (int)y) {
                                 posibilities++;
                         }
                 }
-                while(x <= y);
-                if(n == 5000) posibilities += 2;
+                while(x < y);
+                
                 printf("%d\n", posibilities);