Advertisement
tdttvd

Untitled

Dec 19th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. int main()
  5. {
  6.     int T;
  7.     scanf("%d", &T);
  8.  
  9.     // Lưu kết quả
  10.     bool ans[T];
  11.     int a, b, c, d;
  12.     int max;
  13.  
  14.     for (int i = 0; i < T; ++i)
  15.     {
  16.         // Đọc dữ liệu của testcase
  17.         scanf("%d %d %d %d", &a, &b, &c, &d);
  18.         max = (a > b) ? a : b;
  19.         max = (max < c) ? c : max;
  20.  
  21.         d -= 3*max - (a + b + c);
  22.        
  23.         if ((d >= 0) && (d % 3 == 0)) ans[i] = true;
  24.         else ans[i] = false;
  25.     }
  26.  
  27.     // In ra kết quả
  28.     for (int i = 0; i < T; ++i)
  29.     {
  30.         if (ans[i]) printf("YES\n");
  31.         else printf("NO\n");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement