this is ma code for http://www.spoj.pl/problems/ANARC08H/ musical chairs i m using dynamic programming
for input lik 200000 200000 i m getting seg. fault plz tell hw to modify my program #include<iostream> #include<cstdio> using namespace std; long long arr[10003][10003]; long long f(int n,int k) { if(n==1) return 0; else { //if(arr[n][k]) return arr[n][k]; return /* arr[n][k] = */(f(n-1,k)+k)%n ; } } int main() { int n,k; scanf("%d%d",&n,&k); //cin>>n>>k; while(n && k) { printf("%d %d %lld\n",n,k,f(n,k)+1); //cout<<f(n,k)+1; scanf("%d%d",&n,&k); } return 0; } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.