Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static int WeightCalculation(List<int> weights)
- {
- for (int i = 0; i < weights.Count-1; i++)
- {
- for (int j = i + 1; j < weights.Count; j++)
- {
- if (weights[i] == weights[j])
- {
- weights.RemoveAt(j);
- j--;
- }
- }
- }
- int weight = 0;
- for (int i = 0; i < weights.Count; i++)
- {
- weight += (i + 1) * weights[i];
- }
- return weight;
- }
- static void Main(string[] args)
- {
- int start = int.Parse(Console.ReadLine());
- int end = int.Parse(Console.ReadLine());
- int counter = 0, weight;
- int[] weights = { 5, -12, 47, 7, -32 };
- char[] symbols = { 'a', 'b', 'c', 'd', 'e' };
- List<int> weightsTemp = new List<int>();
- for (int a = 0; a < weights.Length; a++)
- {
- for (int b = 0; b < weights.Length; b++)
- {
- for (int c = 0; c < weights.Length; c++)
- {
- for (int d = 0; d < weights.Length; d++)
- {
- for (int e = 0; e < weights.Length; e++)
- {
- weightsTemp.Add(weights[a]);
- weightsTemp.Add(weights[b]);
- weightsTemp.Add(weights[c]);
- weightsTemp.Add(weights[d]);
- weightsTemp.Add(weights[e]);
- weight = WeightCalculation(weightsTemp);
- if (weight >= start && weight <= end)
- {
- counter++;
- Console.Write("" + symbols[a] + symbols[b] + symbols[c] + symbols[d] + symbols[e] + " ");
- }
- weightsTemp.RemoveRange(0, weightsTemp.Count);
- }
- }
- }
- }
- }
- if (counter == 0)
- {
- Console.Write("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement