Forgot to mention that I'm getting SIGSEV

On Jun 23, 10:32 pm, anonymous procrastination <[email protected]>
wrote:
> Hello,
>
> I tried the question using single array.
> Condition on n,d given is 1000000. So array size goes the same right?
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int f(int n,int d);
> int dp[1000000];
> int main()
> {
>     int n,d,k,t;
>
>     while(1)
>     {
>     for(t=0;t<1000000;t++)
>     dp[t]=0;
>     scanf("%d %d",&n,&d);
>     if((n==0)&&(d==0))
>     break;
>     else
>     printf("%d %d %d\n",n,d,f(n,d)+1);
>     }
>     //system("PAUSE");
>     return 0;
>
> }
>
> int f(int n,int d)
> {
>     if(n==1)
>     return 0;
>     return dp[n]?dp[n]:(dp[n]=(f(n-1,d)+d)%n);
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to