Digital step code language: c

Source: Internet
Author: User
ArticleDirectory
    • Digital steps
Digital step time limit: 1000 ms memory limit: 10000 k total time limit: 3000 Ms

Description:

Starting from the point (0, 0) of the plane coordinate, we can write all non-negative integers 0, 1, 2 ,.......
For example, 1, 2, and 3 are written at (1, 1), (2, 0), and (3, 1) respectively. Then we can continue to write all the numbers in this format:

Now you need to writeProgramRead the coordinate points (x, y) to determine the number (if any) at this point. (x, y) are all numbers between 0 and 5000.

Input:

The first line is the number n (n <1000), indicating the number of test data. Next, there will be n with test data, and each row will have
The two numbers represent the coordinates of X and Y, respectively.

Output:

For the X and Y input in each row, the number of the vertex is output, with one row. If there is no number at this point, print no number.

Input example:

3
4 2
6 6
3 4

Output example:

6
12
No number

Tip:

 

Source:

2006 Northwestern University Program Design Competition finals E

 

Code:

  1. # Include <stdio. h>
  2. # Include <stdlib. h>
  3. Int main ()
  4. {
  5. Int N;
  6. Int I, J;
  7. Scanf ("% d", & N );
  8. Int **;
  9. A = (INT **) malloc (N * sizeof (int *));
  10. For (I = 0; I <n; I ++)
  11. {
  12. A [I] = (int *) malloc (2 * sizeof (INT ));
  13. }
  14. For (I = 0; I <n; I ++)
  15. {
  16. For (j = 0; j <2; j ++)
  17. {
  18. Scanf ("% d", & A [I] [J]);
  19. }
  20. }
  21. For (I = 0; I <n; I ++)
  22. {
  23. If (A [I] [0] % 2 = 0 & A [I] [1] % 2 = 0)
  24. Printf ("% d \ n", a [I] [0] + A [I] [1]);
  25. Else if (a [I] [0] % 2! = 0 & A [I] [1] % 2! = 0)
  26. Printf ("% d \ n", a [I] [0] + A [I] [1]-1 );
  27. Else
  28. Printf ("no number \ n ");
  29. }
  30. Return 0;
  31. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.