Menu Close

[C program]Find the number of pairs if positive intgers(X,Y)…FcukTheCode

Tina’s trainer have given her two positive integers U and V. Now her task is to find the number of pairs if positive intgers(X,Y)
such that 1<=X<=U, 1<=Y<=V and X+Y is even. Tina is finding diffcult to understand the problem.
Can you help her solving the problem?

Input:
The only line of each test case contains two space-separated integers U and V.

Output:
In the Only line of output print a single containing one integer that represents
the number of valid pairs.

Input : 17 5

Output: 43
#include <stdio.h>
int main()
{
int U,V;
int s;
//printf("Enter two positive integers : ");
scanf("%2d%2d",&U,&V);
s=U*V/2+((U%2)*(V%2));
//printf("Valid Pairs : ");
printf("%d\n",s);
return 0;
}

Input_1:
Enter two positive integers : 17 5
Output:
Valid Pairs : 43


Input_2:
Enter two positive integers : 56 24
Output:
Valid Pairs : 672


ILLUSTRATION

Executed using gcc terminal