Go to diff to previous submission
#include <cstdio> #include <vector> #include <iostream> #include <string> #include <algorithm> #include <cstring> using namespace std; int E(int a, int b) { if (b==0) { return a; } else { return E(b, a%b); } } int main() { int n, pocet=0; while (scanf("1/%d\n", &n) > 0) { pocet = 0; //cout << n << endl; for (int x=n+1; x<=2*n; x++) { if ((x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) { //cout << "added " << x-n << " for " << n << endl; pocet++; } } printf("%d\n", pocet); } return 0; }
--- c5.s587.cteam078.fl.cpp.0.fl.cpp +++ c5.s622.cteam078.fl.cpp.0.fl.cpp @@ -23,7 +23,7 @@ pocet = 0; //cout << n << endl; - for (int x=0; x<1000000; x++) { - if ((x-n > 0) && (x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) { -//cout << "added " << x << " for " << n << endl; + for (int x=n+1; x<=2*n; x++) { + if ((x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) { +//cout << "added " << x-n << " for " << n << endl; pocet++; }