-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA. Face Detection.cs
67 lines (56 loc) · 1.54 KB
/
A. Face Detection.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication24
{
public struct Coordinate
{
public int x;
public int y;
public Coordinate(int X,int Y)
{
this.x = X;
this.y = Y;
}
public double Distance(int x1, int y1)
{
return Math.Sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
}
}
class Program
{
static void Main(string[] args)
{
int[] lst = new int[] { 8, 7, 5, 3 };
Console.WriteLine(8 / 5);
Console.WriteLine(8 % 5);
Console.WriteLine(fromNb2Str(187, lst));
Console.ReadLine();
}
public static String fromNb2Str(int n, int[] sys)
{
int mult = 1;
var sb = new StringBuilder();
sb.Append("--");
for (int i = 0 ; i < sys.Count(); i++)
{
sb.Append(n % sys[i]);
sb.Append("--");
mult *= sys[i];
for(int j = i + 1; j < sys.Count(); j++)
{
if (GCD(sys[i], sys[j]) != 1)
return "Not applicable";
}
}
if (mult < n)
return "Not applicable";
return sb.ToString().Substring(1,sb.Length - 2);
}
public static int GCD (int n1, int n2)
{
return n2 == 0 ? n1 : GCD(n2, n1 % n2);
}
}
}