mazaharulhq
BAN USERusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter the number of identical items greater than 0");
string s = Console.ReadLine();
int x = int.Parse(s);
int firstgroup = 1;
abc ob = new abc();
Console.WriteLine(1+ob.NumberOfways(x));
Console.WriteLine();
}
}
class abc
{
public long NumberOfways(int n)
{
long prevalue=0;
for (int c = 1; c <= 3; c++)
prevalue=prevalue+ fact(n - c) / fact(n - c - 1);
return prevalue;
}
public long fact(int number)
{
if (number == 0)
return 1;
else
return number * fact(number - 1);
}
}
}
Follow two steps:-
- mazaharulhq June 09, 20141. First sort the list in any algorithm which uses nlogn complexity.
2.Create the second array.
3.Write down the first instance of all the elements of first array.