Go to diff to previous submission
#include <cstdio> #include <cmath> #include <iostream> #include <string> #include <cstdlib> using namespace std; #define EPS 0.000001 int main() { int c, ch; while (scanf("%d/%d", &ch, &c) == 2) { int times = 0; 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 ); } return 0; }
--- 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 ); }