-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectingTowns.cs
More file actions
40 lines (33 loc) · 1.13 KB
/
ConnectingTowns.cs
File metadata and controls
40 lines (33 loc) · 1.13 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HackerrankSolution
{
public class ConnectingTowns
{
static int connectingTowns(int n, int[] routes)
{
int result = routes.Aggregate(1, (a, b) => (b * a) % 1234567);
return result;
}
public static void Execute()
{
TextWriter textWriter = new StreamWriter(Environment.CurrentDirectory+"\\output.txt", false);
int t = Convert.ToInt32(Console.ReadLine());
for (int tItr = 0; tItr < t; tItr++)
{
int n = Convert.ToInt32(Console.ReadLine());
int[] routes = Array.ConvertAll(Console.ReadLine().Split(' '), routesTemp => Convert.ToInt32(routesTemp))
;
int result = connectingTowns(n, routes);
textWriter.WriteLine(result);
}
textWriter.Flush();
textWriter.Close();
Console.WriteLine(File.ReadAllText(Environment.CurrentDirectory + "\\output.txt"));
}
}
}