aboutsummaryrefslogtreecommitdiff
path: root/c/las12uvas
diff options
context:
space:
mode:
Diffstat (limited to 'c/las12uvas')
-rw-r--r--c/las12uvas/2019/543_tensionEnLasPlayas.cpp46
-rw-r--r--c/las12uvas/2019/544_queNoSeAtraganten.cpp28
-rw-r--r--c/las12uvas/2019/583_toestoEraCampo.cpp15
-rw-r--r--c/las12uvas/2019/584_felizDecadaNueva.cpp13
-rw-r--r--c/las12uvas/2019/585_porElHuecoDeLaEscalera.cpp18
-rw-r--r--c/las12uvas/2019/586_IIII.cpp29
-rw-r--r--c/las12uvas/2019/587_laTiaManuela.cpp38
7 files changed, 187 insertions, 0 deletions
diff --git a/c/las12uvas/2019/543_tensionEnLasPlayas.cpp b/c/las12uvas/2019/543_tensionEnLasPlayas.cpp
new file mode 100644
index 0000000..aa89fde
--- /dev/null
+++ b/c/las12uvas/2019/543_tensionEnLasPlayas.cpp
@@ -0,0 +1,46 @@
+#include <iostream>
+
+int compara(int x1, int y1, int r1,
+ int x2, int y2, int r2)
+{
+ int distSq = (x1 - x2) * (x1 - x2) +
+ (y1 - y2) * (y1 - y2);
+ int radSumSq = (r1 + r2) * (r1 + r2);
+ if (distSq >= radSumSq)
+ return 0;
+ return 1;
+}
+
+int caso() {
+ int sombrillas;
+ int i, j;
+ int solapes = 0;
+
+ std::cin >> sombrillas;
+ int xs[sombrillas];
+ int ys[sombrillas];
+ int rs[sombrillas];
+ for (i = 0; i < sombrillas; i++) {
+ std::cin >> xs[i];
+ std::cin >> ys[i];
+ std::cin >> rs[i];
+ }
+ if (sombrillas < 2) {
+ return 0;
+ }
+ for (i = 0; i < sombrillas-1; i++) {
+ for (j = i+1; j < sombrillas; j++) {
+ if (compara(xs[i], ys[i], rs[i], xs[j], ys[j], rs[j]))
+ solapes++;
+ }
+ }
+ return solapes;
+}
+
+int main() {
+ int casos;
+ for (std::cin >> casos; casos > 0; casos--) {
+ std::cout << caso() << std::endl;
+ }
+ return 0;
+}
diff --git a/c/las12uvas/2019/544_queNoSeAtraganten.cpp b/c/las12uvas/2019/544_queNoSeAtraganten.cpp
new file mode 100644
index 0000000..d5fe0db
--- /dev/null
+++ b/c/las12uvas/2019/544_queNoSeAtraganten.cpp
@@ -0,0 +1,28 @@
+#include <iostream>
+#include <algorithm>
+
+int main() {
+ int uvas, pesoMax;
+ int previo;
+ int total;
+ while (std::cin >> uvas) {
+ std::cin >> pesoMax;
+ int pesos[uvas];
+ for (int i = 0; i < uvas; i++) {
+ std::cin >> pesos[i];
+ }
+ std::sort(pesos, pesos+uvas);
+ previo = 0;
+ total = 0;
+ for (int i = 0; i < uvas; i++) {
+ if (pesos[i] + previo > pesoMax) {
+ break;
+ }
+ total++;
+ previo = pesos[i];
+ }
+ std::cout << total << std::endl;
+ }
+
+ return 0;
+}
diff --git a/c/las12uvas/2019/583_toestoEraCampo.cpp b/c/las12uvas/2019/583_toestoEraCampo.cpp
new file mode 100644
index 0000000..516af4a
--- /dev/null
+++ b/c/las12uvas/2019/583_toestoEraCampo.cpp
@@ -0,0 +1,15 @@
+#include <iostream>
+
+int main() {
+ int abuelo;
+ int iglesia;
+ std::string salida;
+ std::cin >> abuelo;
+ std::cin >> iglesia;
+ while (abuelo || iglesia) {
+ (iglesia > abuelo) ? salida = "SENIL" : salida = "CUERDO";
+ std::cout << salida << std::endl;
+ std::cin >> abuelo;
+ std::cin >> iglesia;
+ }
+}
diff --git a/c/las12uvas/2019/584_felizDecadaNueva.cpp b/c/las12uvas/2019/584_felizDecadaNueva.cpp
new file mode 100644
index 0000000..4c70be2
--- /dev/null
+++ b/c/las12uvas/2019/584_felizDecadaNueva.cpp
@@ -0,0 +1,13 @@
+#include <iostream>
+
+int main() {
+ int primero;
+ int este;
+ std::string salida;
+ while (std::cin >> primero) {
+ std::cin >> este;
+ este = este - primero;
+ ((este+1) % 10 == 0) ? salida = "FELIZ DECADA NUEVA" : salida = "TOCA ESPERAR";
+ std::cout << salida << std::endl;
+ }
+}
diff --git a/c/las12uvas/2019/585_porElHuecoDeLaEscalera.cpp b/c/las12uvas/2019/585_porElHuecoDeLaEscalera.cpp
new file mode 100644
index 0000000..8e82716
--- /dev/null
+++ b/c/las12uvas/2019/585_porElHuecoDeLaEscalera.cpp
@@ -0,0 +1,18 @@
+#include <iostream>
+
+int main() {
+ int casos;
+ int pisos, escalones;
+ int pSubidos, eSubidos;
+ int bajados, subidos;
+ std::cin >> casos;
+ for (int i = 0; i < casos; i++) {
+ std::cin >> pisos;
+ std::cin >> escalones;
+ std::cin >> pSubidos;
+ std::cin >> eSubidos;
+ bajados = pSubidos * escalones + eSubidos;
+ subidos = bajados * 2 + (pisos - pSubidos) * escalones - eSubidos;
+ std::cout << bajados << " " << subidos << std::endl;
+ }
+}
diff --git a/c/las12uvas/2019/586_IIII.cpp b/c/las12uvas/2019/586_IIII.cpp
new file mode 100644
index 0000000..87103db
--- /dev/null
+++ b/c/las12uvas/2019/586_IIII.cpp
@@ -0,0 +1,29 @@
+#include <iostream>
+
+int getGcd(int a, int b) {
+ if (a == 0 && b == 0)
+ return 1;
+ if (a == 0)
+ return b;
+ return b == 0 ? a : getGcd(b, a % b);
+}
+
+int main() {
+ int is, vs, xs;
+ int gcd;
+ int piezas;
+ std::cin >> is;
+ std::cin >> vs;
+ std::cin >> xs;
+ while (is || vs || xs) {
+ gcd = std::min(getGcd(is, vs), std::min(getGcd(vs, xs), getGcd(is, xs)));
+ piezas = is / gcd;
+ piezas += vs / gcd;
+ piezas += xs / gcd;
+ std::cout << piezas << std::endl;
+
+ std::cin >> is;
+ std::cin >> vs;
+ std::cin >> xs;
+ }
+}
diff --git a/c/las12uvas/2019/587_laTiaManuela.cpp b/c/las12uvas/2019/587_laTiaManuela.cpp
new file mode 100644
index 0000000..092dc3d
--- /dev/null
+++ b/c/las12uvas/2019/587_laTiaManuela.cpp
@@ -0,0 +1,38 @@
+#include <iostream>
+#include <vector>
+#include <algorithm>
+
+int cabe(std::vector<int> j, std::vector<int> c) {
+ for (int i = 0; i < 3; i++) {
+ if (j[i] >= c[i]) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+int main() {
+ int casos;
+ std::vector<int> juguete;
+ std::vector<int> caja;
+ int n;
+ std::string salida;
+ std::cin >> casos;
+ for (int i = 0; i < casos; i++) {
+ juguete.clear();
+ caja.clear();
+ for (int j = 0; j < 3; j++) {
+ std::cin >> n;
+ juguete.push_back(n);
+ }
+ for (int j = 0; j < 3; j++) {
+ std::cin >> n;
+ caja.push_back(n);
+ }
+ std::sort(juguete.begin(), juguete.end());
+ std::sort(caja.begin(), caja.end());
+ salida = cabe(juguete, caja) ? "SIRVE" : "NO SIRVE";
+ std::cout << salida << std::endl;
+ }
+}
+