Temabowl

Untitled

Nov 10th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 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. using static System.Math;
  7.  
  8. namespace ConsoleApp1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. int math(int cabbage)
  16. {
  17. if (cabbage <= 2)
  18. {
  19. return 1;
  20. }
  21. int hares = Convert.ToInt32(Sqrt(cabbage));
  22. while (cabbage/hares != cabbage / (hares + 1))
  23. {
  24. hares = hares + 1;
  25. }
  26. return hares;
  27. }
  28.  
  29. int count = Convert.ToInt32(Console.ReadLine());
  30. int[] print = new int[count];
  31. for (int i = 0; i < count; i++)
  32. {
  33. int n = Convert.ToInt32(Console.ReadLine());
  34. print[i] = math(n);
  35.  
  36.  
  37. }
  38. for (int i = 0; i < count;i++)
  39. {
  40. Console.WriteLine(print[i]);
  41. }
  42.  
  43. Console.ReadKey();
  44.  
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment