TOPIC

WRONG ANSWER(5%) EM MEU CÓDIGO...O QUE PODE SER?

Matteus Gutëmberg asked 5 months ago

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int casosTestes, numX, numY, cont = 1;
    scanf("%d", &casosTestes);
    while(cont <= casosTestes){
        scanf("%d %d", &numX, &numY);
            if(numX % 2 == 0){
                int somaImpares = 0;
                for(int i = numX + 1; i <= numX + (numY * 2) - 1; i++)
                    if(i % 2 == 1){
                        somaImpares = somaImpares + i;

                    }
                printf("%d\n", somaImpares);
            }else if(numX % 2 == 1){
                int somaImpares = 0;
                for(int i = numX; i <= numX + (numY * 2) - 1; i++){
                    if(i % 2 == 1){

                        somaImpares = somaImpares + i;

                    }
                }
                printf("%d\n", somaImpares);
            }

        cont++;
    }
    return 0;
}

This topic has not been answered yet. Be the first!

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