Home > Back-end >  Test no problem, but ACM paper shows wrong answer, ask for help
Test no problem, but ACM paper shows wrong answer, ask for help

Time:09-28

Title description
The Description
Starting from point (0, 0) on a plane, we have written all non - negative integers 0, 1, 2,... To in the figure. For example, 1, 2, and 3 has had written at points (1, 1), (2, 0), and (3, 1) respectively and this pattern has continued.



You are to write a program that reads the coordinates of a point (x, y), and writes the number (if any) that has had written at that point. (x, y) coordinates in the input are in the range 0... 5000.
Input
The first line of The input is N, The number of test cases for this problem, In each of The N following lines, there is x, and y representing The coordinates of a point (x, y).
The Output
For each point in the input, and write the number written at that point the or write No number if there is none.
The Sample Input
3
4 2
6 6
3, 4,
The Sample Output
6
12
No Number

My program
# include & lt; stdio.h>
Int main (void)
{
Int p, q, k;
Int I, j, n.
The scanf (" % d ", & amp; N);
for (i=0; i{
The scanf (" % d ", & amp; P);
The scanf (" % d ", & amp; Q);
If (p<=5000 & amp; & Q
=5000){
If (p!=q& & p!=q + 2)
{
Printf (" No Number \ n ");
continue;
}
Else if (p==q)
{
If (p==1) % 2
Printf (" % d \ n ", p * 2-1);
The else
Printf (" % d \ n ", p * 2);
}
The else
{
If (p==2 | | p==3)
{
Printf (" % d \ n ", p);
}
The else
{
P -=1;
K=(p + 1)/2-1;
Printf (" % d \ n, p + k * 2 + 1);
}

}
}

}

return 0;
}


Pray god help,,,, thank you.
  • Related