我實現了一個algorithm
,它打印所有正整數解方程a^3 + b^3 = c^3 + d^3
其中a,b,c,d是介於1和1000之間的整數。 爲此,我使用hash table
將complexity
刪除爲O(N2)
。 H = c^3 + d^3
當我的哈希表超過一定的大小時,爲什麼會出現核心轉儲錯誤?
下面是我用(整數對列表)的hash table
:
int n = 10;
int m = pow(n,3)+pow(n,3);
list< pair<int,int> > hashTable[m+1]; //(*) Core Dump here if n>50. Why?
我的代碼正常時Ñ< = 50。但我無法運行我的algorithm
,因爲n> 50。所以,我無法解決n = 1000的問題。我在行(*)中獲得核心轉儲。你能解釋爲什麼會發生這種情況,並幫助我更好地實施我的hash table
?
謝謝你的時間!
這是寫什麼語言? – ItamarG3