c++ - hangover spoj,解决方案有什么问题?

标签 c++

输入

输入由一个或多个测试用例组成,后跟一行包含数字 0.00 的行,表示输入结束。每个测试用例都是一行,包含一个正 float c,其值至少为 0.01,最多为 5.20; c 将恰好包含三个数字。

输出

对于每个测试用例,输出实现至少 c 卡长度的悬垂所需的最少卡数。使用示例中显示的确切输出格式。

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
float num;
    cin>>num;
    round(num);
    cout<<"0.00"<<endl;
    float temp = 0.00;
    float n=2.00;
    int count1=0;

    while(temp<num)
    {
        temp+=1.0/(n);
        n++;
        count1++;
    }
    cout<<count1<<" card(s)"<<endl;
return 0;
}

最佳答案

The input consists of one or more test cases...

您的代码不适用于“more”。

关于c++ - hangover spoj,解决方案有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29602274/

相关文章:

c++ - Opencv-ocl 可以用不同的硬件执行吗?

c++ - 包含 <cassert> 还是 <assert.h> 更好?

c++ - 如何将函数指针传递给 C++ 中的函数?

c++ - 将 shared_ptr 转换为 auto_ptr?

c++ - 关于 "C4800: ' int' : forcing value to bool 'true' or false'", 的警告为什么?

c++ - 我可以在 opencv 中使用哪个函数作为 matlab 中的 max()

c++ - 返回值部分且确定性地变化

c++ - 如何 "concatenate"boost::mpl::vectors

c++ - 如何检查所有字段是否都已填写? [C++、VS 2015、Windows 窗体]

c++ - 模板类的多个模板模板参数