Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace app
  5. {
  6. public struct Pair
  7. {
  8. public int A;
  9. public int B;
  10.  
  11. public Pair(int a, int b)
  12. {
  13. this.A = a;
  14. this.B = b;
  15. }
  16. }
  17. class Program
  18. {
  19.  
  20. static void Main(string[] args)
  21. {
  22. var count = Convert.ToInt32(Console.ReadLine());
  23. var list = new List<Pair>();
  24.  
  25. for (int i = 0; i < count; ++i)
  26. {
  27. var input = Console.ReadLine().Split();
  28. var pair = new Pair(Convert.ToInt32(input[0]), Convert.ToInt32(input[1]));
  29. list.Add(pair);
  30. }
  31.  
  32. foreach (var pair in list)
  33. {
  34. Console.WriteLine(GetTwoZeros(pair.A, pair.B));
  35. }
  36. }
  37.  
  38. public static string GetTwoZeros(int a, int b)
  39. {
  40. var compare = (b >= a) ? GetCompare(a, b) : GetCompare(b, a);
  41.  
  42. if ((a >= 0 && b >= 0) && compare && VerifyCondition(a, b) && VerifyCondition(b, a))
  43. {
  44. return "YES";
  45. }
  46.  
  47. return "NO";
  48. }
  49.  
  50. public static bool VerifyCondition(int first, int second)
  51. {
  52. return (2 * first - second) % 3 == 0;
  53. }
  54.  
  55. private static bool GetCompare(int min, int max)
  56. {
  57. return max >= 0 && max <= 2 * min;
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement