Files
python/GESP/Level4/GESP202306/4_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

47 lines
756 B
C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 110;
int a[N], al;
// 变换
int change(int y) {
y *= 7;
while (y > 9)
y = y / 10 + y % 10;
return y;
}
// 检查x是不是幸运数
bool check(LL x) {
int idx = 0;
while (x) {
idx++;
int y = x % 10;
x /= 10;
if (idx % 2 == 1) // 奇数位
y = change(y);
// 偶数位不变
a[++al] = y;
}
LL q = 0;
// 反着拼回来
for (int i = al; i; i--)
q = q * 10 + a[i];
return q % 8 == 0;
}
int main() {
int N;
cin >> N;
while (N--) {
al = 0;
LL x;
cin >> x;
if (check(x))
cout << "T" << endl;
else
cout << "F" << endl;
}
return 0;
}