Advertisement
tungSfer

Untitled

May 27th, 2021
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define el endl
  5. #define umi unordered_map<int, int>
  6. #define umll unordered_map<ll, ll>
  7. #define all(vect) vect.begin(), vect.end()
  8. #define reset(A) memset(A, 0, sizeof(A))
  9. #define approx(n) fixed << setprecision(n)
  10.  
  11. const int mod = 1e9 + 7;
  12.  
  13. using namespace std;
  14.  
  15. int palin(char s[500]) {
  16.     int st = 0, en = strlen(s) -1;
  17.     while (st <= en) {
  18.         if (s[st] != s[en])
  19.             return 0;
  20.         st++;
  21.         en--;
  22.     }
  23.     return 1;
  24. }
  25.  
  26. int sum(char s[500])
  27. {
  28.     int tong=0;
  29.     for(int i=0; i<strlen(s); i++)
  30.         tong += (s[i] - '0');
  31.     return tong;
  32. }
  33. int main ()
  34. {
  35.     int t;
  36.     scanf("%d",&t);
  37.     while (t--) {
  38.        char s[1000];
  39.        scanf("%s",&s);
  40.        if(s[0] != '8' || s[strlen(s) - 1] != '8' || sum(s) % 10 || !palin(s))
  41.        {
  42.             printf("NO\n");
  43.        }
  44.        else
  45.             printf("YES\n");
  46.        
  47.        }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement