Advertisement
Guest User

TestNumbersSCharp

a guest
May 28th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 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. if (sum >= maxSum)
  21. {
  22. Console.WriteLine($"{count} combinations");
  23. Console.WriteLine($"Sum: {sum} >= {maxSum}");
  24. return;
  25. }
  26.  
  27. else
  28. {
  29. count++;
  30. sum += 3 * (i * j);
  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