这是我的代码
#include <iostream>
#include <cstdlib>
class Block{
private:
int* costs;
const static int sz=1000000000;
void generate_dp_costs(){
for(int i=0;i<sz;i++){
int cut_cost = costs[int(i/2)] + costs[int(i/3)] + costs[int(i/4)];
costs[i] = std::max(i, cut_cost);
}
}
public:
Block(){
costs = (int*)malloc((sz+1)*sizeof(int));
generate_dp_costs();
}
int optimum_cost(int weight){
return costs[weight];
}
};
int main(){
Block b;
int weight,cost;
std::cin>>weight;
cost = b.optimum_cost(weight);
std::cout<<cost<<std::endl;
}
它使program.exe停止使用code :: blocks在构建和运行时工作,但在ideone等在线编译器上工作正常。这可能是什么问题?