martes, 3 de marzo de 2015

solucion 386 cubos perfectos


 *
 * @author DAM116
 */
public class UVA386_CubosPerfectos {

    public static void main(String[] args) {
        int cubo[] = new int[201];
        for (int i = 1; i <= 200; i++) {
            cubo[i] = i * i * i;
        }
        for (int a = 6; a <= 200; a++) {
            for (int b = 2; b < a; b++) {
                for (int c = b + 1; c < a; c++) {
                    for (int d = c + 1; d < a; d++) {
                        if (cubo[a] == cubo[b] + cubo[c] + cubo[d]) {
                            System.out.println("Cube = " + a + ", Triple = (" + b + "," + c + "," + d + ")");
                        }
                    }
                }
            }
        }
    }
}





OTRA SOLUCION





/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package UVA_Pendientes;

/**
 *
 * @author DAM116
 */
public class UVA386_CubosPerfectosPrint {

    public static void main(String[] args) {
        System.out.println("Cube = 6, Triple = (3,4,5)");
        System.out.println("Cube = 12, Triple = (6,8,10)");
        System.out.println("Cube = 18, Triple = (2,12,16)");
        System.out.println("Cube = 18, Triple = (9,12,15)");
        System.out.println("Cube = 19, Triple = (3,10,18)");
        System.out.println("Cube = 20, Triple = (7,14,17)");
        System.out.println("Cube = 24, Triple = (12,16,20)");
        System.out.println("Cube = 25, Triple = (4,17,22)");
        System.out.println("Cube = 27, Triple = (3,18,24)");
        System.out.println("Cube = 28, Triple = (18,19,21)");
        System.out.println("Cube = 29, Triple = (11,15,27)");
        System.out.println("Cube = 30, Triple = (15,20,25)");
        System.out.println("Cube = 36, Triple = (4,24,32)");
        System.out.println("Cube = 36, Triple = (18,24,30)");
        System.out.println("Cube = 38, Triple = (6,20,36)");
        System.out.println("Cube = 40, Triple = (14,28,34)");
        System.out.println("Cube = 41, Triple = (2,17,40)");
        System.out.println("Cube = 41, Triple = (6,32,33)");
        System.out.println("Cube = 42, Triple = (21,28,35)");
        System.out.println("Cube = 44, Triple = (16,23,41)");
        System.out.println("Cube = 45, Triple = (5,30,40)");
        System.out.println("Cube = 46, Triple = (3,36,37)");
        System.out.println("Cube = 46, Triple = (27,30,37)");
        System.out.println("Cube = 48, Triple = (24,32,40)");
        System.out.println("Cube = 50, Triple = (8,34,44)");
        System.out.println("Cube = 53, Triple = (29,34,44)");
        System.out.println("Cube = 54, Triple = (6,36,48)");
        System.out.println("Cube = 54, Triple = (12,19,53)");
        System.out.println("Cube = 54, Triple = (27,36,45)");
        System.out.println("Cube = 56, Triple = (36,38,42)");
        System.out.println("Cube = 57, Triple = (9,30,54)");
        System.out.println("Cube = 58, Triple = (15,42,49)");
        System.out.println("Cube = 58, Triple = (22,30,54)");
        System.out.println("Cube = 60, Triple = (21,42,51)");
        System.out.println("Cube = 60, Triple = (30,40,50)");
        System.out.println("Cube = 63, Triple = (7,42,56)");
        System.out.println("Cube = 66, Triple = (33,44,55)");
        System.out.println("Cube = 67, Triple = (22,51,54)");
        System.out.println("Cube = 69, Triple = (36,38,61)");
        System.out.println("Cube = 70, Triple = (7,54,57)");
        System.out.println("Cube = 71, Triple = (14,23,70)");
        System.out.println("Cube = 72, Triple = (8,48,64)");
        System.out.println("Cube = 72, Triple = (34,39,65)");
        System.out.println("Cube = 72, Triple = (36,48,60)");
        System.out.println("Cube = 75, Triple = (12,51,66)");
        System.out.println("Cube = 75, Triple = (38,43,66)");
        System.out.println("Cube = 76, Triple = (12,40,72)");
        System.out.println("Cube = 76, Triple = (31,33,72)");
        System.out.println("Cube = 78, Triple = (39,52,65)");
        System.out.println("Cube = 80, Triple = (28,56,68)");
        System.out.println("Cube = 81, Triple = (9,54,72)");
        System.out.println("Cube = 81, Triple = (25,48,74)");
        System.out.println("Cube = 82, Triple = (4,34,80)");
        System.out.println("Cube = 82, Triple = (12,64,66)");
        System.out.println("Cube = 82, Triple = (19,60,69)");
        System.out.println("Cube = 84, Triple = (28,53,75)");
        System.out.println("Cube = 84, Triple = (42,56,70)");
        System.out.println("Cube = 84, Triple = (54,57,63)");
        System.out.println("Cube = 85, Triple = (50,61,64)");
        System.out.println("Cube = 87, Triple = (20,54,79)");
        System.out.println("Cube = 87, Triple = (26,55,78)");
        System.out.println("Cube = 87, Triple = (33,45,81)");
        System.out.println("Cube = 87, Triple = (38,48,79)");
        System.out.println("Cube = 88, Triple = (21,43,84)");
        System.out.println("Cube = 88, Triple = (25,31,86)");
        System.out.println("Cube = 88, Triple = (32,46,82)");
        System.out.println("Cube = 89, Triple = (17,40,86)");
        System.out.println("Cube = 90, Triple = (10,60,80)");
        System.out.println("Cube = 90, Triple = (25,38,87)");
        System.out.println("Cube = 90, Triple = (45,60,75)");
        System.out.println("Cube = 90, Triple = (58,59,69)");
        System.out.println("Cube = 92, Triple = (6,72,74)");
        System.out.println("Cube = 92, Triple = (54,60,74)");
        System.out.println("Cube = 93, Triple = (32,54,85)");
        System.out.println("Cube = 95, Triple = (15,50,90)");
        System.out.println("Cube = 96, Triple = (19,53,90)");
        System.out.println("Cube = 96, Triple = (48,64,80)");
        System.out.println("Cube = 97, Triple = (45,69,79)");
        System.out.println("Cube = 99, Triple = (11,66,88)");
        System.out.println("Cube = 100, Triple = (16,68,88)");
        System.out.println("Cube = 100, Triple = (35,70,85)");
        System.out.println("Cube = 102, Triple = (51,68,85)");
        System.out.println("Cube = 103, Triple = (12,31,102)");
        System.out.println("Cube = 105, Triple = (33,70,92)");
        System.out.println("Cube = 106, Triple = (58,68,88)");
        System.out.println("Cube = 108, Triple = (12,72,96)");
        System.out.println("Cube = 108, Triple = (13,51,104)");
        System.out.println("Cube = 108, Triple = (15,82,89)");
        System.out.println("Cube = 108, Triple = (24,38,106)");
        System.out.println("Cube = 108, Triple = (54,72,90)");
        System.out.println("Cube = 110, Triple = (29,75,96)");
        System.out.println("Cube = 111, Triple = (16,47,108)");
        System.out.println("Cube = 112, Triple = (72,76,84)");
        System.out.println("Cube = 113, Triple = (50,74,97)");
        System.out.println("Cube = 114, Triple = (18,60,108)");
        System.out.println("Cube = 114, Triple = (57,76,95)");
        System.out.println("Cube = 115, Triple = (3,34,114)");
        System.out.println("Cube = 116, Triple = (23,86,97)");
        System.out.println("Cube = 116, Triple = (30,84,98)");
        System.out.println("Cube = 116, Triple = (44,60,108)");
        System.out.println("Cube = 117, Triple = (13,78,104)");
        System.out.println("Cube = 120, Triple = (9,55,116)");
        System.out.println("Cube = 120, Triple = (42,84,102)");
        System.out.println("Cube = 120, Triple = (60,80,100)");
        System.out.println("Cube = 121, Triple = (49,84,102)");
        System.out.println("Cube = 122, Triple = (19,92,101)");
        System.out.println("Cube = 123, Triple = (6,51,120)");
        System.out.println("Cube = 123, Triple = (18,96,99)");
        System.out.println("Cube = 123, Triple = (44,51,118)");
        System.out.println("Cube = 125, Triple = (20,85,110)");
        System.out.println("Cube = 126, Triple = (14,84,112)");
        System.out.println("Cube = 126, Triple = (23,94,105)");
        System.out.println("Cube = 126, Triple = (63,84,105)");
        System.out.println("Cube = 127, Triple = (13,65,121)");
        System.out.println("Cube = 129, Triple = (38,57,124)");
        System.out.println("Cube = 132, Triple = (5,76,123)");
        System.out.println("Cube = 132, Triple = (48,69,123)");
        System.out.println("Cube = 132, Triple = (66,88,110)");
        System.out.println("Cube = 133, Triple = (21,70,126)");
        System.out.println("Cube = 134, Triple = (44,102,108)");
        System.out.println("Cube = 134, Triple = (86,95,97)");
        System.out.println("Cube = 135, Triple = (15,90,120)");
        System.out.println("Cube = 137, Triple = (44,73,128)");
        System.out.println("Cube = 138, Triple = (9,108,111)");
        System.out.println("Cube = 138, Triple = (69,92,115)");
        System.out.println("Cube = 138, Triple = (72,76,122)");
        System.out.println("Cube = 138, Triple = (81,90,111)");
        System.out.println("Cube = 139, Triple = (94,96,99)");
        System.out.println("Cube = 140, Triple = (14,108,114)");
        System.out.println("Cube = 140, Triple = (49,98,119)");
        System.out.println("Cube = 140, Triple = (90,95,105)");
        System.out.println("Cube = 141, Triple = (72,85,122)");
        System.out.println("Cube = 142, Triple = (28,46,140)");
        System.out.println("Cube = 142, Triple = (31,64,137)");
        System.out.println("Cube = 144, Triple = (16,96,128)");
        System.out.println("Cube = 144, Triple = (68,78,130)");
        System.out.println("Cube = 144, Triple = (72,96,120)");
        System.out.println("Cube = 145, Triple = (12,81,136)");
        System.out.println("Cube = 145, Triple = (55,75,135)");
        System.out.println("Cube = 147, Triple = (22,75,140)");
        System.out.println("Cube = 150, Triple = (24,102,132)");
        System.out.println("Cube = 150, Triple = (71,73,138)");
        System.out.println("Cube = 150, Triple = (75,100,125)");
        System.out.println("Cube = 150, Triple = (76,86,132)");
        System.out.println("Cube = 151, Triple = (46,47,148)");
        System.out.println("Cube = 152, Triple = (24,80,144)");
        System.out.println("Cube = 152, Triple = (62,66,144)");
        System.out.println("Cube = 153, Triple = (17,102,136)");
        System.out.println("Cube = 156, Triple = (65,87,142)");
        System.out.println("Cube = 156, Triple = (78,104,130)");
        System.out.println("Cube = 159, Triple = (3,121,131)");
        System.out.println("Cube = 159, Triple = (87,102,132)");
        System.out.println("Cube = 160, Triple = (56,112,136)");
        System.out.println("Cube = 160, Triple = (69,123,124)");
        System.out.println("Cube = 162, Triple = (18,108,144)");
        System.out.println("Cube = 162, Triple = (36,57,159)");
        System.out.println("Cube = 162, Triple = (50,96,148)");
        System.out.println("Cube = 162, Triple = (59,93,148)");
        System.out.println("Cube = 162, Triple = (81,108,135)");
        System.out.println("Cube = 164, Triple = (8,68,160)");
        System.out.println("Cube = 164, Triple = (24,128,132)");
        System.out.println("Cube = 164, Triple = (38,120,138)");
        System.out.println("Cube = 164, Triple = (69,99,146)");
        System.out.println("Cube = 167, Triple = (12,86,159)");
        System.out.println("Cube = 168, Triple = (56,106,150)");
        System.out.println("Cube = 168, Triple = (84,112,140)");
        System.out.println("Cube = 168, Triple = (108,114,126)");
        System.out.println("Cube = 170, Triple = (96,107,141)");
        System.out.println("Cube = 170, Triple = (100,122,128)");
        System.out.println("Cube = 171, Triple = (19,114,152)");
        System.out.println("Cube = 171, Triple = (27,90,162)");
        System.out.println("Cube = 171, Triple = (54,80,163)");
        System.out.println("Cube = 171, Triple = (107,108,136)");
        System.out.println("Cube = 174, Triple = (40,108,158)");
        System.out.println("Cube = 174, Triple = (45,126,147)");
        System.out.println("Cube = 174, Triple = (47,97,162)");
        System.out.println("Cube = 174, Triple = (52,110,156)");
        System.out.println("Cube = 174, Triple = (66,90,162)");
        System.out.println("Cube = 174, Triple = (76,96,158)");
        System.out.println("Cube = 174, Triple = (87,116,145)");
        System.out.println("Cube = 175, Triple = (28,119,154)");
        System.out.println("Cube = 176, Triple = (25,92,167)");
        System.out.println("Cube = 176, Triple = (42,86,168)");
        System.out.println("Cube = 176, Triple = (50,62,172)");
        System.out.println("Cube = 176, Triple = (64,92,164)");
        System.out.println("Cube = 177, Triple = (48,137,142)");
        System.out.println("Cube = 178, Triple = (34,80,172)");
        System.out.println("Cube = 178, Triple = (48,133,147)");
        System.out.println("Cube = 179, Triple = (17,57,177)");
        System.out.println("Cube = 180, Triple = (20,120,160)");
        System.out.println("Cube = 180, Triple = (50,76,174)");
        System.out.println("Cube = 180, Triple = (63,126,153)");
        System.out.println("Cube = 180, Triple = (90,120,150)");
        System.out.println("Cube = 180, Triple = (116,118,138)");
        System.out.println("Cube = 181, Triple = (108,109,150)");
        System.out.println("Cube = 184, Triple = (12,144,148)");
        System.out.println("Cube = 184, Triple = (108,120,148)");
        System.out.println("Cube = 185, Triple = (57,68,180)");
        System.out.println("Cube = 185, Triple = (68,113,166)");
        System.out.println("Cube = 186, Triple = (18,121,167)");
        System.out.println("Cube = 186, Triple = (64,108,170)");
        System.out.println("Cube = 186, Triple = (93,124,155)");
        System.out.println("Cube = 187, Triple = (58,131,160)");
        System.out.println("Cube = 188, Triple = (115,122,149)");
        System.out.println("Cube = 189, Triple = (21,46,188)");
        System.out.println("Cube = 189, Triple = (21,126,168)");
        System.out.println("Cube = 190, Triple = (30,100,180)");
        System.out.println("Cube = 190, Triple = (56,133,163)");
        System.out.println("Cube = 191, Triple = (39,146,156)");
        System.out.println("Cube = 192, Triple = (34,123,173)");
        System.out.println("Cube = 192, Triple = (38,106,180)");
        System.out.println("Cube = 192, Triple = (96,128,160)");
        System.out.println("Cube = 193, Triple = (25,68,190)");
        System.out.println("Cube = 194, Triple = (90,138,158)");
        System.out.println("Cube = 196, Triple = (126,133,147)");
        System.out.println("Cube = 197, Triple = (53,58,194)");
        System.out.println("Cube = 198, Triple = (22,132,176)");
        System.out.println("Cube = 198, Triple = (27,46,197)");
        System.out.println("Cube = 198, Triple = (73,135,170)");
        System.out.println("Cube = 198, Triple = (99,132,165)");
        System.out.println("Cube = 199, Triple = (6,127,180)");
        System.out.println("Cube = 200, Triple = (32,136,176)");
        System.out.println("Cube = 200, Triple = (70,140,170)");
    }

}


No hay comentarios:

Publicar un comentario