1 条题解

  • 0
    @ 2024-8-2 16:19:45

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        int x = 1; // 当前这一层应该有多少个石头
        int ans = 0; // 搭建了多少层
    
        while (n >= x) {
            ans++;
            n = n - x;
            x = x + 1;
    	}
            if (ans < 100)
                cout << 100 - ans;
            else if (ans == 100)
                cout << 0;
            else
                cout << ans - 100;
        
    
        return 0;
    }
    
    

    信息

    ID
    1022
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    3
    已通过
    3
    上传者