Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace SimpleCSharpApp
  6. {
  7. class Program
  8. {
  9. public static long sum = 0;
  10. public static long n = 0;
  11.  
  12. public static void Main()
  13. {
  14. n = Convert.ToInt64(Console.ReadLine());
  15.  
  16. string output = "";
  17. long count = 0;
  18. long temp = 0;
  19.  
  20. if (n > 1)
  21. {
  22. for (long i = 1; i < n; i++)
  23. {
  24. temp = n - sum;
  25.  
  26. if (i < temp - i)
  27. {
  28. sum += i;
  29. output += (i.ToString() + " ");
  30. count++;
  31. }
  32. else
  33. {
  34. output += (temp.ToString() + " ");
  35. count++;
  36. sum += temp;
  37. break;
  38. }
  39. }
  40. }
  41. else
  42. {
  43. output += "1 ";
  44. count++;
  45. }
  46.  
  47. Console.WriteLine(count.ToString());
  48.  
  49. Console.WriteLine(output);
  50. Console.Read();
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement