-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEIUSUBSET.cs
86 lines (78 loc) · 2.34 KB
/
EIUSUBSET.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EIUSUBSET
{
class Program
{
static void Main(string[] args)
{
var t = NextInt();
var arr = new List<int>();
var newArray = new List<string>();
while (t-- > 0)
{
arr.Add(NextInt());
}
for (int i = arr.Count-1; i >=0; i--)
{
string tmp = "";
for (int j = i; j < arr.Count; j++)
{
tmp += arr[j] + " ";
newArray.Add(tmp);
}
}
StringBuilder result = new StringBuilder();
result.Append(newArray.Count + "\n");
for (int i = 0; i <newArray.Count; i++)
{
result.Append(newArray[i] +"\n");
}
Console.Write(result);
}
static int s_index = 0;
static List<string> s_tokens;
private static string Next()
{
while (s_tokens == null || s_index == s_tokens.Count)
{
s_tokens = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
s_index = 0;
}
return s_tokens[s_index++];
}
private static bool HasNext()
{
while (s_tokens == null || s_index == s_tokens.Count)
{
s_tokens = null;
s_index = 0;
var nextLine = Console.ReadLine();
if (nextLine != null)
{
s_tokens = nextLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
else
{
return false;
}
}
return s_tokens.Count > 0;
}
private static int NextInt()
{
return Int32.Parse(Next());
}
private static double NextDouble()
{
return double.Parse(Next());
}
private static long NextLong()
{
return Int64.Parse(Next());
}
}
}