FLAGS - Editorial

But in flag 4, no.3 and 4 can have same colors as they are not sharing any side, same case for flag 5, 1 and 4 are not sharing any side they also can share same color.
So there must also be added a case for 3 colors in flag 4 and 5, as n*(n-1)*(n-2)

hey friends i wrote solution for this que in java and is working fine with my compiler ,but while submitting this solution its written run time error (nzec) please help me , now what to do…

import java.util.*;

public class Main{

public static void main(String[] args) {
    

  
    //System.out.println("enter the test case ");
    Scanner a = new Scanner(System.in);
    int t=a.nextInt();
      int arr[]=new int[t];
      int ans[]=new int[t];



  for (int i=0;i<t;i++){
      
     //System.out.println("enter the no of colour ");

      Scanner b=new Scanner(System.in);
       arr[i] =b.nextInt();
       
       int x= arr[i];
       
      ans[i]= 2*x*(x-1)*(x-1) + x*(x-1)*(x-2) + 2*x*(x-1)*(x-2)*(x-2);
      
  }       
   
   for(int temp: ans)
   { System.out.println(" "+temp);
    
    
 }

}
}

i hav a doubt suppose i
input int n;
and store this expression value in long long x;
and output x
will it typecast the “int” to “long long”
if yes,its not happening…WHY???

n should be long long int…if you are taking n as int then typecast it to long long int while evaluating expression…