fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. bool ends_in_3(int sum)
  5. {
  6. return sum % 10 == 3;
  7. }
  8. void solve()
  9. {
  10. int t;
  11. cin >> t;
  12. while (t--)
  13. {
  14. int n;
  15. cin >> n;
  16. vector<int> a(n);
  17. for (int i = 0; i < n; i++)
  18. {
  19. cin >> a[i];
  20. }
  21. bool found = false;
  22. for (int i = 0; i < n ; i++)
  23. {
  24. for (int j = i + 1; j < n; j++)
  25. {
  26. for (int k = j + 1; k < n ; k++)
  27. {
  28. int sum = a[i] + a[j] + a[k];
  29. if (ends_in_3(sum))
  30. {
  31. found = true;
  32. break;
  33. }
  34. }
  35. }
  36. }
  37. if (found)
  38. {
  39. cout << "YES" << endl;
  40. }
  41. else
  42. {
  43. cout << "NO" << endl;
  44. }
  45. }
  46. }
  47. int main()
  48. {
  49. solve();
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
NO