FIBEASY : can someone help me about my code , however it"s working but On submission it shows WA

using namespace std;

int main() {
	// your code goes here
int  t,n;
int j =0;
	cin>>t>>n;
	while(t--){
	    int F[n];
	    if(n==1){F[0] = 0;}
	        if(n==2){F[1] = 1;
	            F[0] = 0;
	        }
	    for(int i = 0;i<n;i++){
	    	if(i==0){
	    		F[i] = 0;
			}
			else if(i ==1){
				F[i] = 1;
			}
		else	
	        {
				   F[i] = F[i-1] +F[i-2]    ;  }
	    }
	
	int D[n],E[n/2+2];
	
	for(int i = 0;i<n;i++){
		D[i] = F[i]%10;
	}
	
	
	
	
	
	if(n == 1){
	    return 0;
	    
	}
	else{
	    while(n >1){
	       
	        j = 0;
	        for(int i =0;i<n;i++){
	            if(i%2){
	                
	           E[j] = D[i];
	           j++;}
	            }n =j;
	            D[n];
	            
	          
	           for(int i =0;i<j;i++){
	               D[i] = E[i];
	           }
	    }    
	    
	  
	cout<<D[0];
	}
}
	return 0;
}

Please either format your code or link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Edit:

Assuming this is what you want to check - it gives no output for the testcase

1
1
1 Like

@ssjgz It is mentioned in challenge to end the process if l =1.

  • Let D=(D1,D2,…,Dl)
  • If l=1 the process ends.

Yes - the process ends, and then you have to print the number remaining :slight_smile: