Advertisement
Guest User

TestNumbersSCharp-Solution

a guest
May 28th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _12.TestNumbers
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10. int m = int.Parse(Console.ReadLine());
  11. int maxSum = int.Parse(Console.ReadLine());
  12.  
  13. int count = 0;
  14. int sum = 0;
  15.  
  16. for (int i = n; i >= 1; i--)
  17. {
  18. for (int j = 1; j <= m; j++)
  19. {
  20.  
  21.  
  22. count++;
  23. sum += 3 * (i * j);
  24.  
  25. if (sum >= maxSum)
  26. {
  27. Console.WriteLine($"{count} combinations");
  28. Console.WriteLine($"Sum: {sum} >= {maxSum}");
  29. return;
  30. }
  31.  
  32. }
  33. }
  34. Console.WriteLine($"{count} combinations");
  35. Console.WriteLine($"Sum: {sum}");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement