Wednesday, August 03, 2011

[UVa] 386 - Perfect Cubes

The live calculating solution I made gives correct output, but somehow the judge gets it wrong. So I printed the result in a file and then created a printf() for printing the precalculated values. Got AC. It means the judge compiler has some problem. Anyways, here's the deal. If you need to generate the output, just uncomment the code.

#include <stdio.h>
/*
int cubes[8000001]={0};
struct lc
{
    int num;
    int i, j, k;
} list[500]={0,0,0,0};

int cmp(const void *a, const void *b)
{
    if (((struct lc*)a)->num != ((struct lc*)b)->num)
        return (((struct lc*)a)->num - ((struct lc*)b)->num);
    else
        return (((struct lc*)a)->k - ((struct lc*)b)->k);
}


void cuber(int lim)
{
    int i, j, k, l=0, x;

    for (i=0 ; i<=lim ; i++)
    {
        cubes[i*i*i]=0;
    }

    for (i=2 ; i<=lim ; i++)
    {
        cubes[i*i*i]=i;
    }

    for (i=2 ; i<=lim ; i++)
    {
        for (j=2 ; j<=i ; j++)
        {
            for (k=2 ; k<=j ; k++)
            {
                x = i*i*i + j*j*j + k*k*k;

                if (x>8000000) break;

                if (cubes[x])
                {
                    list[l].k=k;
                    list[l].j=j;
                    list[l].i=i;
                    list[l].num=cubes[x];
                    l++;
                }
            }
        }
    }

    qsort(list,l,sizeof(struct lc),cmp);
    for (i=0 ; i<l ; i++)
    {
        printf("Cube = %d, Triple = (%d,%d,%d)\\n\\\n",list[i].num,list[i].k,list[i].j,list[i].i);
    }
}
*/



int main()
{
    /*freopen("minso.txt","w+",stdout);*/

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

    /*cuber(200);*/
    return 0;
}

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...