首页 > 解决方案 > C++,不能处理大于 10^5 的数字的问题

问题描述

每当我尝试使用大于 10^6 的 R 时,控制台不会返回任何内容。我的目标是 L、R、n、br 的数量能够达到 10^18。谢谢帮助。
我的代码:

#include<iostream>
#include<cmath>

using namespace std;

int main() {
    long long L, R, br=0;
    double p,q,r;   
    cin>>p>>q>>r>>L>>R;
    for (long long n=L; n<=R; n++) {
        if (    
            ceil(n/p)+ceil(n/q)+ceil(n/r)<=n
        ){br++;}        
    }
    cout<<br;
    return 0;
}


标签: c++

解决方案


推荐阅读