You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
/*
首先,我们要录进来一个数
先做个函数吧!
要bool的
int a[n];
bool xy(int n)要一个数,
进行判断
{先怎么办呢?
先数位分离:
需要什么?
需要一个n,把它分离后,
存储到一个数组里:
int al=0;
while(n){
int t=n%10;
a[++al]=t;
n/=10;
}
a里面是什么
a中是分离好的数以便后来判断是奇数位还是偶数位
开始判断!
注意如题目所示个位为一十位为2所以不需把
最高为放在a[1]处
分为两种情况:
1.偶数位,不做改变 注意,先判断偶数,会更清晰
2.奇数位需要1.a[奇数位]*=7 2.if(a[奇数位]>9)
a[i]=按位相加(此处可为函数大致是a[i]=a[i]%10+
a[i]/10)
那么,目前捋完了。
怎么打呢?
int t=0;
for(int i=al;i;i--)t=t*10+a[i];
该看看它是否%8==0;
if(t%8==0)return true;
else return false;
}
*/
int a[100];
int ys(int n) {
while (n > 9)
n = n % 10 + n / 10;
return n;
}
bool xy(int n) {
int al = 0;
while (n) {
int t = n % 10;
a[++al] = t;
n /= 10;
}
for (int i = 1; i <= al; i++) {
if (i % 2)
a[i] = ys(a[i] * 7);
}
int t = 0;
for (int i = al; i; i--)
t = t * 10 + a[i];
return !(t % 8);
}
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
if (xy(n))
cout << "T" << endl;
else
cout << "F" << endl;
}
return 0;
}