less than 1 minute read

Problem Statement

Explanation

This might seem like a math problem. But it’s not. There’s a pattern in here. Firstly, figure out when output has no number. If you can figure it out then try to recognise the relation of the output with co-ordinates (x, y)

Code

#include<stdio.h>
int main()
{
    int t,x,y;
    scanf("%d",&t);
    while(t--&&t>=0)
    {
        scanf("%d%d",&x,&y);
        if(y==x||y==x-2)
        {
            if(x%2==0) printf("%d\n",x+y);
            else printf("%d\n",x+y-1);
        }
        else
        {
            printf("No Number\n");
        }
    }

}

Updated:

Comments