Program.cs 923 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. namespace D02._2
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) return;
  11. if (File.Exists(args[0]) == false) throw new FileNotFoundException();
  12. int ft = 0;
  13. using (var file = File.OpenText(args[0]))
  14. {
  15. while (true)
  16. {
  17. var line = file.ReadLine();
  18. if (line == null) break;
  19. var dim = line.Split("x").Select(s => int.Parse(s)).ToArray();
  20. int l = dim[0], w = dim[1], h = dim[2];
  21. int peri1 = 2 * l + 2 * w, peri2 = 2 * w + 2 * h, peri3 = 2 * h + 2 * l;
  22. ft += Math.Min(peri1, Math.Min(peri2, peri3)) + l * h * w;
  23. }
  24. }
  25. Console.WriteLine($"Answer is : {ft}");
  26. }
  27. }
  28. }