#牛客春招刷题训练营# + 链接
#include <cmath> #include <iostream> using namespace std; /*本来不想写的rd, 奈何超时了*/template<typename T> inline void rd(T& x){ char c = getchar(); x = 0; while(c > '9' || c < '0') {c = getchar();} while(c <= '9' && c >= '0') {x = (x << 3)+(x << 1)+(c&15); c=getchar();} } template<typename T1, typename T2, typename ...Args> inline void rd(T1& x, T2& xx, Args&... arg) {rd(x); rd(xx, arg...);} int main() { //ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int T; rd(T); while(T--){ int n, m; rd(n, m); while(m--){ if (n > 4) n = ceil(sqrt(n));//----------注意向上取整 else if(n > 2) n = (n + 1) / 2;//---------注意是向上取整 else { n -= (m + 1);//---------这里注意不要一个一个减,会超时 break; } } cout << n << '\n'/*endl*/;//-------用'\n'比endl快 } } // 64 位输出请用 printf("%lld")