From b6403b910fb4a7f2658027804dae3c01e1a473b4 Mon Sep 17 00:00:00 2001 From: Lucas Virgili Date: Sun, 20 May 2012 12:18:34 -0300 Subject: [PATCH] 91 --- Lvl4/euler91.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Lvl4/euler91.cpp diff --git a/Lvl4/euler91.cpp b/Lvl4/euler91.cpp new file mode 100644 index 0000000..1a5bf35 --- /dev/null +++ b/Lvl4/euler91.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() { + int L = 50; + unsigned cnt = 3*L*L; + for (int x1 = 2; x1 <= L; ++x1) { + for (int x2 = 1; x2 < x1; ++x2) { + for (int y = 1; y <= L; ++y) { + if ((x2*x2 + y*y - x1*x2) == 0) { + cnt += 2; + } + } + } + } + for (int x1 = 2; x1 <= L; ++x1) { + for (int x2 = 1; x2 < x1; ++x2) { + for (int y2 = 2; y2 <= L; ++y2) { + for (int y1 = 1; y1 < y2; ++y1) { + if ((x1*x1 + y1*y1 - x1*x2 - y1*y2) == 0) { + cnt += 2; + } + } + } + } + } + cout << cnt << endl; + return 0; +}