#include using namespace std;

int main() { int n; cin >> n;

int ans = 0;
int length = 1;
while (n > 0) {
    if (n >= length) {
        n -= length;
        length++;
        ans++;
    } else {
        length = 1;
    }
}

cout << ans << endl;

return 0;

}

C++ 实现必须符合样例:有 n 个木棍长度分别为 123……n现在明明有一把刀每次选定一个长度进行切割若木棍长度小于选定值则不切割多个木棍可以同时切割现在明明想计算至少需要切多少刀可以将所有木棍的长度都变为 0你能帮明明找找答案吗?1根木棍1:以长度1为单位切 1 刀后长度变为 0;总共至少需要 1 刀;2根木根12:以长度 1 为单位切 1 刀后长度变为 01再以长度 1 为单位切一刀后长度变

原文地址: https://www.cveoy.top/t/topic/id5p 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录