这么坑!!!

我把int改成double把1/n改成1.0/n然后就过了!!!

2 条评论

  • @ 2017-01-19 17:40:55

    当然是这样

  • @ 2016-11-09 21:46:30
    
    评测结果
    
    
    编译成功
    
    测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    
    测试数据 #1: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    
    测试数据 #2: Accepted, time = 15 ms, mem = 560 KiB, score = 10
    
    测试数据 #3: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    
    测试数据 #4: Accepted, time = 0 ms, mem = 560 KiB, score = 10
    
    Accepted, time = 15 ms, mem = 560 KiB, score = 50
    
    
    代码
    
    #include<iostream>
    using namespace std;
    int k,n=1;
    double ans=0;
    int main()
    {
      cin>>k;
      while(1)
      {
        ans+=1.0/n;
        if(ans>k)
          break;
        n++;
      }
      cout<<n;
      return 0;
    }
    
    
  • 1

信息

ID
1127
难度
4
分类
模拟 点击显示
标签
递交数
10631
已通过
4835
通过率
45%
被复制
36
上传者