TLE怎么办,不能这样写吗
查看原帖
TLE怎么办,不能这样写吗
863381
a_blue_shao楼主2025/6/27 20:16
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn=20;
ll cat(ll x)
{
	x *= 7;
	if(x <= 9)
		return x;
	else
	{
		x = (x % 10) + x/10;
		if(x > 9)
			return cat(x);
		else
			return x; 
	}
}
int main()
{
	int n ;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		ll ans = 0;
		ll num;
		cin >> num;
		for(ll j = 1; num > 0;num /= 10, j++)
		{
			ll d=num % 10;
			if(j % 2 == 0)
			{
				ans += d;		
			}

			else
			{
				ans += cat(d);
			}
		}
		if(ans % 8 == 0)
			cout << "T" << endl;
		else
			cout << "F" << endl;
		
	} 
	return 0;
}
2025/6/27 20:16
加载中...