题解 | 小数字

小数字

https://www.nowcoder.com/practice/faaaa4ddadb34bae88b37fcb635654f1

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, m;
        cin >> n >> m;
        while (n && m) {
            int t = n;
            int x = sqrt(t);
            if (x * x != t) x++;
            n = min({n, x, t - 1, (t + 1) / 2}), m--;
        }
        n -= m;
        cout << n << endl;
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务