Advertisement
Guest User

Test_Number

a guest
Jan 28th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Test_Numbers
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int m = int.Parse(Console.ReadLine());
  15. int stop = int.Parse(Console.ReadLine());
  16.  
  17. int combinationsSum = 0;
  18. int count = 0;
  19. bool isNumber = false;
  20.  
  21. for (int i = n; i >=1; i--)
  22. {
  23. for (int k = 1; k <= m; k++)
  24. {
  25. combinationsSum += + 3 * (i * k);
  26. count++;
  27. if (combinationsSum >= stop)
  28. {
  29. isNumber = true;
  30. Console.WriteLine($"{count} combinations");
  31. Console.WriteLine($"Sum: {combinationsSum} >= {stop}");
  32. return;
  33. }
  34.  
  35. }
  36.  
  37. }
  38. if (!isNumber)
  39. {
  40. Console.WriteLine($"{count} combinations");
  41. Console.WriteLine($"Sum: {combinationsSum}");
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement