1 / 5
Aug 2013

Problem code: PALIN
ID: 9841432
Please tell me how can I make it more compact.
It shows time limit exceeded.

  • created

    Aug '13
  • last reply

    Jun '18
  • 4

    replies

  • 991

    views

  • 5

    users

4 years later

Here’s my solution.
I’m also having the same problem.[Time limit exceeded]
#include
using namespace std;
int divisor( int n)
{
int j=0,i;
for(i=1;i<n;i++)
{
if(n%i==0)
{
j=i+j;
}
}
return j;
}
int main()
{
int i,j,n,x=0,t;
cin>>t;
for(t;x<t;x++)
{
cin>>i;
j=divisor(i);
cout<<j<<endl;
}
return 0;

Did you notice how big this number can be?

1 month later

This is my code for prime generator (Time Limit exceeded)
#include
using namespace std;
int main()
{int t;
cin>>t;
long long int a[t],b[t];
for(int i=0;i<t;i++)
cin>>a[i]>>b[i];
for(int i=0;i<t;i++)
{
for(int j=a[i];j<=b[i];j++)
{
int c=0;
for(int k=2;k<j;k++)
{
if(j%k!=0)
c++;
}
if(c==j-2)
cout<<j<<endl;
}
cout<<endl;
}
return 0;

}

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 17 10d

Want to read more? Browse other topics in C and C++ or view latest topics.