Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace SimpleCSharpApp
- {
- class Program
- {
- public static long sum = 0;
- public static long n = 0;
- public static void Main()
- {
- n = Convert.ToInt64(Console.ReadLine());
- string output = "";
- long count = 0;
- long temp = 0;
- if (n > 1)
- {
- for (long i = 1; i < n; i++)
- {
- temp = n - sum;
- if (i < temp - i)
- {
- sum += i;
- output += (i.ToString() + " ");
- count++;
- }
- else
- {
- output += (temp.ToString() + " ");
- count++;
- sum += temp;
- break;
- }
- }
- }
- else
- {
- output += "1 ";
- count++;
- }
- Console.WriteLine(count.ToString());
- Console.WriteLine(output);
- Console.Read();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement