求救!!!
查看原帖
求救!!!
870787
Hendsome楼主2023/11/5 20:01

我这个while循环怎么10个点都是TLE啊,救救我吧

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int cnt = 0, ans;
  while(n > 0)
  {
  	if(n % 3 == 1) ans = cnt;
  	cnt++;
   n = n - ceil(n / 3);
  }
  cout << cnt << " " << ans;
  return 0;
}
2023/11/5 20:01
加载中...