2 / 2
Apr 2019

So i have that code

#include
using namespace std;

int wynik, a, ile;

int silnia(int m)
{
if(m==1) return 1;
else return m*silnia(m-1);
}

int main()
{
cin >> ile;
for(int i=0; i<ile; i++)
{
cin >> a;
wynik = silnia(a);
cout << (wynik%100 - wynik%10)/10 << " " << wynik%10;
}

return 0;

}

Since, before it said the time limit has been exceeded, so i have that new code. To make it faster i used recursion, but it still says that the time limit has been exceeded, wth am i supposed to do???

  • created

    Apr '19
  • last reply

    Apr '19
  • 1

    reply

  • 751

    views

  • 2

    users

  • 1

    link

Recursion doesn’t usually make code run faster.

Take a look here13 for an explanation.

Suggested Topics

Want to read more? Browse other topics in System SPOJ or view latest topics.