当前位置:网站首页>Memory Limit Exceeded
Memory Limit Exceeded
2022-06-30 17:35:00 【换个名字就很好】
死循环导致
不一定是因为自己显式地创建的变量过多,比如创建过多的列表,字典等等。
可能是死循环,自己写循环没有使得循环出口的关键变量在循环过程中变化,
循环在跑,内存一直增加,导致超出内存限制。
比如下面的求某一个数的因子,初始化因子fac为1,
每次循环,fac理应要自增1,但是忘了写,
就会报错说内存超限,
它没报TLE,所以就很难发觉。
def get_fac(self, target):
if target == 1:
return []
fac = 1
facs = []
while fac*fac <= target:
if target % fac == 0: # in O(N)
facs.append(fac) # list index O(N)
if fac != 1 and fac*fac != target:
facs.append(target//fac)
# fac += 1 # 这里忘了写
return facs
列表导致
可能是列表占内存很大,换成字典后就可以了,这种情况仅适用于可以用字典代替的情况。
边栏推荐
猜你喜欢

MySQL事务并发问题和MVCC机制

医疗行业企业供应链系统解决方案:实现医疗数智化供应链协同可视

Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills

Tsinghua only ranks third? 2022 release of AI major ranking of Chinese Universities of soft science

The online procurement system of the electronic components industry accurately matches the procurement demand and leverages the digital development of the electronic industry

In distributed scenarios, do you know how to generate unique IDs?

Research on the principle of Tencent persistence framework mmkv

Sword finger offer 16 Integer power of numeric value

剑指 Offer 17. 打印从1到最大的n位数

php利用队列解决迷宫问题
随机推荐
Rhai - Rust 的嵌入式脚本引擎
《所谓情商高,就是会说话》读书笔记
AI首席架构师10-AICA-蓝翔 《飞桨框架设计与核心技术》
音频 librosa 库 与 torchaudio 库中 的 Mel- spectrogram 进行对比
分布式事务
Do you really understand the persistence mechanism of redis?
手机股票账号开户安全吗?是靠谱的吗?
这里数据过滤支持啥样的sql语句
mysql for update 死锁问题排查
Vscode status bar statusbar
PyTorch学习(三)
One script of unity actual combat realizes radar chart
剑指 Offer 16. 数值的整数次方
详解单例模式
Compilation problems and solutions of teamtalk winclient
Development and construction of NFT mining tour gamefi chain tour system
Dlib库实现人脸关键点检测(Opencv实现)
国内离线安装 Chrome 扩展程序的方法总结
countdownlatch 和 completableFuture 和 CyclicBarrier
Deep learning compiler understanding