Source code for submission s757

Go to diff to previous submission

fl.cpp

  1. #include <cstdio>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdlib>
  6.  
  7. using namespace std;
  8.  
  9. #define EPS 0.000001
  10.  
  11. int main()
  12. {
  13. int c, ch;
  14. while (scanf("%d/%d", &ch, &c) == 2)
  15. {
  16. int times = 0;
  17. for ( int x = c + 1; x <= 2 * c; x++)
  18. {
  19. double z = x * c/double(x-c);
  20. if ( abs ( z - int(z) ) < EPS )
  21. times++;
  22. }
  23. printf( "%d\n", times );
  24. }
  25. return 0;
  26. }
  27.  

Diff to submission s647

fl.cpp

--- c5.s647.cteam044.fl.cpp.0.fl.cpp
+++ c5.s757.cteam044.fl.cpp.0.fl.cpp
@@ -11,12 +11,14 @@
 int main()
 {
-        int c;
-        while (scanf("%*d/%d", &c))
+        int c, ch;
+        while (scanf("%d/%d", &ch, &c) == 2)
         {
                 int times = 0;
-                double n = c;
-                for ( double x = n; x <= 2*n; x++ )
-                        if ( abs ( x*n/(x-n) - int( x*n/(x-n) ) ) < EPS )
+                for ( int x = c + 1; x <= 2 * c; x++)
+                {
+                        double z = x * c/double(x-c);
+                        if ( abs ( z - int(z) ) < EPS )
                                 times++;
+                }
                 printf( "%d\n", times );
         }