如何“摆脱”TLE?
查看原帖
如何“摆脱”TLE?
579727
Plum_Steven楼主2022/2/4 12:40
#include <iostream>
using namespace std;

int main()
{
    int n=1, k;
    float total;
    cin >> k;
    
    while(1)
    {
        total += 1 / n;
        n++;
        if (total > k)
        {
            break;
        }
    }
    cout << total;
    return 0;
}
2022/2/4 12:40
加载中...