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; n =1; while (cin) { cin >> input; if (input.empty()) break; n = atoi(input.c_str()+2); //n++; 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++; } pouzite.clear(); while (true) { if((x*n)%(x-n)==0) { y = x*n/(x-n); if (y < x) break; pocet++; if (y == x) break; } x++; } /*/ //int x1=-1; //cout<<"Number "<<n<<endl; while (x <= n*2) { if((x*n)%(x-n)==0) { //Spocitat y y = x*n/(x-n); //if (y < x) break; pocet++; //cout<<" "<<x<<"|"<<y<<endl; //if (y == x) break; //zjistit, jestli sme zase na zacatku /*if(y==x1) break; //Zapamatovat si prvni x if(x1==-1) x1=x;*/ } x++; } /*while (x < n*(n+1)) { if (x%n == 0) pocet++; x++; }*/ y = 0; x = 0; cout << pocet << "\n"; pocet = 0; // } return 0; }
--- c5.s834.cteam016.fl.cpp.0.fl.cpp +++ c5.s905.cteam016.fl.cpp.0.fl.cpp @@ -12,7 +12,7 @@ n = x = y = pocet = 0; string input; - vector<unsigned long> pouzite; + //vector<unsigned long> pouzite; bool nasel = false; - + n =1; while (cin) { @@ -20,4 +20,5 @@ if (input.empty()) break; n = atoi(input.c_str()+2); + //n++; x = n+1; if (n == 0) @@ -56,6 +57,6 @@ } x++; - }/*/ - + } + pouzite.clear(); while (true) { @@ -71,12 +72,42 @@ x++; } -//*/ +/*/ + //int x1=-1; + //cout<<"Number "<<n<<endl; + + while (x <= n*2) + { + if((x*n)%(x-n)==0) + { + + //Spocitat y + y = x*n/(x-n); + + //if (y < x) break; + + pocet++; + //cout<<" "<<x<<"|"<<y<<endl; + //if (y == x) break; + //zjistit, jestli sme zase na zacatku + /*if(y==x1) + break; + //Zapamatovat si prvni x + if(x1==-1) + x1=x;*/ + } + x++; + } + + /*while (x < n*(n+1)) + { + if (x%n == 0) pocet++; + x++; + }*/ y = 0; x = 0; cout << pocet << "\n"; pocet = 0; - pouzite.clear(); + // } - cout << "\n"; return 0; }