the program is exiting after taking the first two lines as input without giving any output. can You tell me why?

Viewed 27

int main(void) {
    int T;
    scanf("%d", &T);
    if(T<1 || T>10^5) return 0;
    while(T--)
    {
        int N, K;
        scanf("%d%d", &N, &K);
        if(N<1 || N>10^9 || K<1 || K>10^4) return 0;
        if(N>=(K*(K+1)/2))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

input:

4
3 4
30 3
2 2
1 1

problem: the program is exiting after taking the first two lines as input without giving any output.

its working fine if I do this(comment the if statements):

#include <stdio.h>

int main(void) {
    int T;
    scanf("%d", &T);
    //if(T<1 || T>10^5) return 0;
    while(T--)
    {
        int N, K;
        scanf("%d%d", &N, &K);
        //if(N<1 || N>10^9 || K<1 || K>10^4) return 0;
        if(N>=(K*(K+1)/2))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}
0 Answers
Related