我正在解决 SPOJ 问题FLIB,我已经尝试使用这样的地图来实现它 -
long long FiboSum(long long n) {
if(n==1||n==0) return n;
if(fiboDict.count(n)) return (long long) fiboDict.at(n);
if(n%2==0) {
//calculate term -- value to that key
fiboDict.insert(pair<long,long>(n,term));
}
else {
//calculate term
fiboDict.insert(pair<long,long>(n,term));
}
return (long long) fiboDict.at(n);
}
fiboDict
是地图,但问题需要我计算,( 0 <= n < 2^51)
但 KEY 值不能保持这么高的值,我得到错误
terminate called after throwing an instance of 'std::out_of_range' what():
map::at
我怎样才能让它保持大的价值?或者如果有其他选择,请提出建议。