40TLE dalao!!!求助
查看原帖
40TLE dalao!!!求助
712373
HA_HA_HA楼主2022/10/24 16:23
#define qwe if(x % 3 == 0){x /= 3;}
using namespace std;
long long x, k;
int main()
{
	cin >> x >> k;
	while(1)
	{ 	 
		int p = 3 - (x % 3); 
		if(k - p >= 0)
		{
			x = x / 3 + 1;
			k -= p;
			if(k == 0)
			{
				cout << x;
				return 0;
			}	
		}
		else
		{
			if(k == 0)
			{
				cout << x;
				return 0;
			}
			else if(k == 1)
			{
				cout << x + 1;
				return 0;
			}
			else if(k == 2)
			{
				if(x % 3 == 0)
				{
					x /= 3;
				}
				else
				{
					x ++;
				}
				if(x % 3 == 0)
				{
					x /= 3;
				}
				else
				{
					x ++;
				}
				cout << x;
				return 0;
			}
			else
			{
				if(x % 3 == 0)
				{
					x /= 3;
				}
				else
				{
					x ++;
				}
				if(x % 3 == 0)
				{
					x /= 3;
				}
				else
				{
					x ++;
				}
				if(x % 3 == 0)
				{
					x /= 3;
				}
				else
				{
					x ++;
				}
				cout << x;
				return 0;
			} 
		}
	}
	return 0;
}
2022/10/24 16:23
加载中...