TOPIC

Tomando 5 % com todos testes batendo no udebug !!

Renan Alcoléa asked 2 years ago

#include<stdio.h>

int main() {

   int N,X,Y,i,cont=0,sum=0;

   scanf("%d", &N);

   for(i=0;i<N;i++){
       scanf("%d %d", &X,&Y);
       do
       {
           if(X%2==1){
             sum+=X;
             X++;
             cont++;
           }
           X++;
       }while(cont!=Y);
       printf("%d\n", sum);
       sum = cont =0;
   }
   return 0;
}

O que pode ser ?

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

  • feodorv replied 2 years ago

    The problem statement doesn't define the limits for X and Y. So Y can be zero or negative. I advise you to rewrite the code as

    while( cont < Y )
    {
      ...
    }