I - MaratonIME divides fairly

左手的ㄟ右手 2022-05-16 09:04 217阅读 0赞

Statements

In a country trip, the contestants decided to play a soccer match. Yan, who was a professional player once, decided not to play to keep the teams balanced. He wanted to participate in another way, so he decided to choose the two teams.

Unfortunately, unlike soccer, Yan is very bad at math and doesn’t know if he divided the teams fairly. Yan considers a division fair if the absolute difference between the number of players in each team is minimum. Can you help him?

Input

The first line has a single integer T, the number of test cases. The next T lines have two integers a and b, the number of players in each team.

  • 1 ≤ T ≤ 1000.
  • 0 ≤ a, b ≤ 109.

Output

Print T lines, one for each test case.

If Yan was fair, output the word “Ok”.

If Yan wasn’t fair, output two integers x and y, x ≤ y, the sizes of the teams in a fair division.

Example

Input

  1. 2
  2. 2 2
  3. 0 2

Output

  1. Ok
  2. 1 1

题目大意及思路:给你2个数,来判断。如果他们相等或者差距为1的话,直接输出OK,反之,相加除以2.

输出的话。前面的数小于后面的数。

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. int main()
  5. {
  6. int t, sum, a, b;
  7. scanf("%d", &t);
  8. while(t--)
  9. {
  10. scanf("%d%d", &a, &b);
  11. sum = a + b;
  12. if(a == b || a + 1 == b || b + 1 == a)
  13. {
  14. printf("Ok\n");
  15. }
  16. else if(sum % 2 == 0)
  17. {
  18. printf("%d %d\n", sum / 2, sum / 2);
  19. }
  20. else
  21. {
  22. printf("%d %d\n", sum / 2, sum / 2 + 1);
  23. }
  24. }
  25. return 0;
  26. }

发表评论

表情:
评论列表 (有 0 条评论,217人围观)

还没有评论,来说两句吧...

相关阅读