Codechef : Problem name " 7 Rings " solution in C#

 =======================Solution answer for the same ============================

using System;

public class Test

{

public static void Main()

{

    int t=Convert.ToInt32(Console.ReadLine());

for(int j=0;j<t;j++){

   string[] array=Console.ReadLine().Split(' ');

    int N=Convert.ToInt32(array[0]);

    int X=Convert.ToInt32(array[1]);

    int costTotal=N*X;

    string variable=costTotal.ToString();

    if(variable.Length == 5){

        for(int i=0; i<variable.Length;i++){

            if(variable[0]!=0){

               Console.WriteLine("YES");

               break;

            }

        }

    }

    else

    Console.WriteLine("NO");

}

}

}

==============================Explanation================================
We are calculating total cost from the input given by simply multiplying N and X ( Line 9 to 13)

(Line 15 to 26)
As we have calculated the cost we have converted it to string value ( as we need to check if it is satisfying condition of phone number which are it should be of length 5 and should not start with 0 ) checking if the length is equal to 5 or not , if yes then continue for next step we are looping character by character and checking for the first char value if it is 0 or not, if not 0 then print desired output

Comments