Go to diff to previous submission
#include <iostream> #include <string> #include <cstdlib> #include <cstdio> #include <vector> using namespace std; int main () { unsigned long n, x, y, pocet; n = x = y = pocet = 0; string input; vector<unsigned long> pouzite; bool nasel = false; while (cin) { cin >> input; if (input.empty()) break; n = atoi(input.c_str()+2); x = n+1; if (n == 0) { cout << 0 << "\n"; continue; } if (n == 1) { cout << 1 << "\n"; continue; } while (float((x*n)%(x-n)) < n+1) { if((x*n)%(x-n)==0) { y = x*n/(x-n); //if (y < x) break; nasel = false; for (vector<unsigned long>::iterator i = pouzite.begin(); i != pouzite.end(); i++) { if ((*i) == y) { nasel = true; break; } } if (!nasel) { pouzite.push_back(x); pocet++; } //pocet++; //if (y == x) break; } x++; } y = 0; x = 0; cout << pocet << "\n"; pocet = 0; pouzite.clear(); } return 0; }
--- c5.s815.cteam016.fl.cpp.0.fl.cpp +++ c5.s823.cteam016.fl.cpp.0.fl.cpp @@ -13,4 +13,5 @@ string input; vector<unsigned long> pouzite; + bool nasel = false; while (cin) @@ -30,11 +31,11 @@ continue; } - while (true) + while (float((x*n)%(x-n)) < n+1) { if((x*n)%(x-n)==0) { y = x*n/(x-n); - if (y < x) break; - /*nasel = false; + //if (y < x) break; + nasel = false; for (vector<unsigned long>::iterator i = pouzite.begin(); i != pouzite.end(); i++) { @@ -48,8 +49,9 @@ { pouzite.push_back(x); - }*/ - pocet++; + pocet++; + } + //pocet++; - if (y == x) break; + //if (y == x) break; } x++; @@ -59,4 +61,5 @@ cout << pocet << "\n"; pocet = 0; + pouzite.clear(); } return 0;