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 (((n*x) % (x-n)) ==0) { //cout << "added " << x-n << " for " << n << endl; ++pocet; } } /* for (int i = 1; i <= n; ++i) { if ((n % i) == 0) { ++pocet; } }*/ printf("%d\n", pocet); } return 0; }
--- c5.s622.cteam078.fl.cpp.0.fl.cpp +++ c5.s645.cteam078.fl.cpp.0.fl.cpp @@ -23,10 +23,19 @@ 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)) { + for (int x=n+1; x<=2*n; ++x) { + if (((n*x) % (x-n)) ==0) + { //cout << "added " << x-n << " for " << n << endl; - pocet++; + ++pocet; } } +/* + for (int i = 1; i <= n; ++i) + { + if ((n % i) == 0) + { + ++pocet; + } + }*/ printf("%d\n", pocet);