Source code for submission s583

Go to diff to previous submission

fl.cpp

  1. #include <cstdio>
  2. #include <cmath>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int isInt( double y )
  7. {
  8. return abs(y - round(y)) <= 0.0000001;
  9. }
  10.  
  11. int main()
  12. {
  13. int n;
  14. while( scanf("1/%d", &n) )
  15. {
  16. double y;
  17. int x = 2*n;
  18. int count = 0;
  19. for( x = n+1; x <= 2*n; x++ )
  20. {
  21. y = (double)(n*x) / (double)(x-n);
  22. if( isInt(y) )
  23. count ++;
  24. }
  25.  
  26. printf( "%d\n", count );
  27. }
  28.  
  29. return 0;
  30. }
  31.  
  32.  

Diff to submission s579

fl.cpp

--- c5.s579.cteam031.fl.cpp.0.fl.cpp
+++ c5.s583.cteam031.fl.cpp.0.fl.cpp
@@ -6,5 +6,5 @@
 int isInt( double y )
 {
-        return abs(y - round(y)) <= 0.00001;
+        return abs(y - round(y)) <= 0.0000001;
 }