-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThousandDigit(Long)
57 lines (37 loc) · 1.27 KB
/
ThousandDigit(Long)
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ThousandDigit
{
class Program
{
static void Main(string[] args)
{
Console.SetIn(new StreamReader(@"E:\testInput\Input.txt"));
Console.SetOut(new StreamWriter(@"E:\testInput\Output.txt") { AutoFlush = true});
const int WINDOW = 13;
string str = Console.ReadLine();
char[] ch = str.ToCharArray();
int sp = 0;
int fp = sp + WINDOW;
long maxProduct = 0;
while(fp != ch.Length - 1) {
var currentList = ch
.Where((c, i) => i >= sp && i < fp)
.Select(x => (long)Char.GetNumericValue(x)).ToList();
var currentProduct = currentList
.Aggregate((p, cc) => cc * p);
if(maxProduct <= currentProduct)
maxProduct = currentProduct;
sp++;
fp = sp + WINDOW;
}
Console.WriteLine(maxProduct);
//foreach (var x in List)
// Console.WriteLine(x);
}
}
}