直接把每个数字取出来,全排列看下是不是4的倍数

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define mem(a,b) memset(a,b,sizeof(a))
#define x first
#define y second
constexpr ll inf = 1e18;
constexpr ll mod = 998244353;
constexpr ll MOD = 1e9 + 7;

int ten[10];

void init() {
    ten[0] = 1;
    for (int i = 1; i < 10; i++) {
        ten[i] = ten[i - 1] * 10;
    }
}

void solve() {
    int n;
    cin >> n;
    vector<int> a;
    while(n) {
        a.push_back(n % 10);
        n /= 10;
    }
    sort(a.begin(), a.end());
    do{
        int sum = 0;
        for (int i = 0; i < a.size(); i++) {
            sum += a[i] * ten[i];
        }
        if (sum % 4 == 0) {
            cout << "YES" << '\n';
            return ;
        }
    }while(next_permutation(a.begin(), a.end()));
    cout << "NO" << '\n';
}

int main() {
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;
    cin >> T;
    init();
    while(T--) {
        solve();
    }
    return 0;
}