|
|
вернуться в форумplease help, crash... stack overflow, here's code: Послано radio 21 май 2008 05:33 #include <iostream.h> #define MAX 10000000 using namespace std; int main() { __int64 k,p,i; __int64 A[MAX]; cin>>k>>p;
A[0] = 0; A[1] = 1 % p; for(i = 2; i <= k; i++){ if(i % 2 == 0) A[i] = (A[i-1] + A[i / 2]) % p; else A[i] = A[i-1] % p; } cout<<A[k-1]; return 0; } Edited by author 21.05.2008 05:37 Re: please help, crash... stack overflow, here's code: local variables are located in stack, so if you want to avoid stack overflow(crash) you can't declare big arrays inside functions int main() { __int64 k,p,i; __int64 A[MAX]; => __int64 A[MAX]; int main() { __int64 k,p,i; |
|
|