Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Задача_2
  4. {
  5.     class Задача552
  6.     {
  7.         static void Main()
  8.         {
  9.             Int64 countAnimalsTypes = Int64.Parse(Console.ReadLine());
  10.             string[] numbers = Console.ReadLine().Split(' ');
  11.             int[] countAnimals = new int[numbers.Length];
  12.             for (int index = 0; index < numbers.Length; index++)
  13.             {
  14.                 countAnimals[index] = int.Parse(numbers[index]);
  15.             }
  16.  
  17.             Int64[] combinations = new Int64[3];
  18.             if (countAnimalsTypes > 2)
  19.             {
  20.                 for (int index = 0; index < countAnimalsTypes; index++)
  21.                 {
  22.                     combinations[2] = combinations[2] + combinations[1] * countAnimals[index];
  23.                     combinations[1] = combinations[1] + combinations[0] * countAnimals[index];
  24.                     combinations[0] = combinations[0] + countAnimals[index];
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine(combinations[2]);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement