TOPIC

Time Limit Exceeded

Joy asked 1 year ago

include

int main() { float A,B; double C,D; int m1,m2,m3,m4;

while(1)
{
    scanf("%f%f",&A,&B);
    scanf("%lf%lf",&C,&D);

    printf("A = %f, B = %f\n",A,B);
    printf("C = %lf, D = %lf\n",C,D);
    printf("A = %.1f, B = %.1f\n",A,B);
    printf("C = %.1lf, D = %.1lf\n",C,D);
    printf("A = %.2f, B = %.2f\n",A,B);
    printf("C = %.2lf, D = %.2lf\n",C,D);
    printf("A = %.3f, B = %.3f\n",A,B);
    printf("C = %.3lf, D = %.3lf\n",C,D);
    printf("A = %.3E, B = %.3E\n",A,B);
    printf("C = %.3E, D = %.3E\n",C,D);

    m1 = (int)A;
    m2 = (int)B;
    m3 = (int)C;
    m4 = (int)D;

    printf("A = %d, B = %d\n",m1,m2);
    printf("C = %d, D = %d\n\n",m3,m4);

} }

That is the code. But it's showing time limit exceeded. Where is the problem? Thanks.

Remember not post solutions. Your post may be reviewed by our moderators.

  • feodorv replied 1 year ago

    Where is the problem?

    In this code:

    while(1)
    {
      ...
    }

    This cicle is infinite. No condition to break it. This problem does not require such cicle, it's with single input case.