← Playground

Create adventOfCode20.cpp

a4efe58e790f6e74cddef19cef3553f2927d792d · darakna · Jan 15, 2016 12:30

+40 · 1 file changed

  • adventOfCode20.cpp +40 −0
diff --git a/adventOfCode20.cpp b/adventOfCode20.cpp
new file mode 100644
index 0000000..0ac0c76
--- /dev/null
+++ b/adventOfCode20.cpp
@@ -0,0 +1,40 @@
+// AoCD20.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include<iostream>
+#include<string>
+#include<cstdint>
+
+int main()
+{
+	int64_t present = 36000000;
+	int64_t curent_pres = 0;
+	int64_t found = 0;
+	while (found == 0)
+	{
+		for (int64_t casa = 1; casa <= present; casa++)
+		{
+			curent_pres = 0;
+			for (int64_t ren = 1; ren <= casa; ren++)
+			{
+				if (casa % ren == 0)
+				{
+
+					curent_pres = curent_pres + ren * 10;
+					if (curent_pres == present)
+					{
+						std::cout << casa << std::endl;
+						break;
+					}
+				}
+			}
+			std::cout << "House " << casa << " got " << curent_pres << " presents." << std::endl;
+
+		}
+
+	}
+	
+    return 0;
+}
+