大型输入C++上的运行时错误

Runtime error on large input C++

本文关键字:运行时错误 C++ 输入 大型      更新时间:2023-10-16

当n<(10^4)。但对于10^5这样的输入,ideone会提供运行时错误plz帮助视频链接代码

enter code here
#include <iostream>
using namespace std;
int main()
{
    long long int t,i=0,n,j,sum;
    cin>>t;
    while(i<t)
    {
        cin>>n;
        cout<<n+1<<endl;
        sum=(n*(n+1))/2;
        cout<<sum<<endl;
        for(j=0;j<=n;j++)
        cout<<j<<" ";
        i++;
        cout<<endl;
    }
    return 0;
}

输出的大小必须是Ideone中的<=64KB。即使考虑到sizeof(int)=4,它也将运行最大n=16000。这将为您提供输出限制的粗略估计。