bastien.monsarrat 6 năm trước cách đây
mục cha
commit
68dd976d47

+ 12 - 0
Adv2015.sln

@@ -73,6 +73,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "D19.1", "D19.1\D19.1.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D19.2", "D19.2\D19.2.csproj", "{BE97EB79-038F-445E-9604-C77CA4CEE115}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D20.1", "D20.1\D20.1.csproj", "{5365CA31-8F39-4B5D-9F42-AD3B7D23CA8D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D20.2", "D20.2\D20.2.csproj", "{2303B37A-6752-415A-824C-BCF146EB613D}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -219,6 +223,14 @@ Global
 		{BE97EB79-038F-445E-9604-C77CA4CEE115}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{BE97EB79-038F-445E-9604-C77CA4CEE115}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{BE97EB79-038F-445E-9604-C77CA4CEE115}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5365CA31-8F39-4B5D-9F42-AD3B7D23CA8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5365CA31-8F39-4B5D-9F42-AD3B7D23CA8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5365CA31-8F39-4B5D-9F42-AD3B7D23CA8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5365CA31-8F39-4B5D-9F42-AD3B7D23CA8D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{2303B37A-6752-415A-824C-BCF146EB613D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2303B37A-6752-415A-824C-BCF146EB613D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2303B37A-6752-415A-824C-BCF146EB613D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2303B37A-6752-415A-824C-BCF146EB613D}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 9 - 0
D20.1/D20.1.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D20._1</RootNamespace>
+  </PropertyGroup>
+
+</Project>

+ 35 - 0
D20.1/Program.cs

@@ -0,0 +1,35 @@
+using System;
+
+namespace D20._1
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+            var input = int.Parse(args[0]);
+
+            int max = input / 10;
+            int test = 0;
+
+            while (test < max)
+            {
+                var result = SumOfDivisors(test) * 10;
+                if (result >= input) break;
+                test++;
+            }
+
+            Console.WriteLine($"The answer is : {test}");
+        }
+
+        private static int SumOfDivisors(int number)
+        {
+            int result = 0;
+            int sqrt = (int)Math.Sqrt(number) + 1;
+
+            for (int divisor = 1; divisor < sqrt; divisor++)
+                if (number % divisor == 0) result += divisor + number / divisor;
+            return result;
+        }
+    }
+}

+ 8 - 0
D20.1/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D20.1": {
+      "commandName": "Project",
+      "commandLineArgs": "33100000"
+    }
+  }
+}

+ 9 - 0
D20.2/D20.2.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <RootNamespace>D20._2</RootNamespace>
+  </PropertyGroup>
+
+</Project>

+ 35 - 0
D20.2/Program.cs

@@ -0,0 +1,35 @@
+using System;
+
+namespace D20._2
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            if (args.Length < 1) throw new ArgumentException();
+            var input = int.Parse(args[0]);
+
+            int max = input / 11;
+            int test = 0;
+
+            while (test < max)
+            {
+                var result = SumOfDivisors(test) * 11;
+                if (result >= input) break;
+                test++;
+            }
+
+            Console.WriteLine($"The answer is : {test}");
+        }
+
+        private static int SumOfDivisors(int number)
+        {
+            int result = 0;
+            int sqrt = (int)Math.Sqrt(number) + 1;
+
+            for (int divisor = 1; divisor <= 50; divisor++)
+                if (number % divisor == 0) result += divisor + number / divisor;
+            return result;
+        }
+    }
+}

+ 8 - 0
D20.2/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "D20.2": {
+      "commandName": "Project",
+      "commandLineArgs": "33100000"
+    }
+  }
+}