How many matches do you need?

How many matches do you need to build a cuboid containing 2020 cubes?

The side of each cube is one match.


The answer is 7060.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

If you want to accept this solution, you have to test the formulas. Here is a picture, what can help:

Let's do some formulas:

If there is a cuboid with side lengths a , b and c , we need D 3 [ a , b , c ] D_{3[a,b,c]} matches, where D 3 [ a , b , c ] = a ( b + 1 ) ( c + 1 ) + b ( a + 1 ) ( c + 1 ) + c ( a + 1 ) ( b + 1 ) D_{3[a,b,c]}=a(b+1)(c+1)+b(a+1)(c+1)+c(a+1)(b+1) (1. formula) , because:

We can divide this cuboid to a b a*b rectangles c + 1 c+1 times. Between this rectangles there are c ( a + 1 ) ( b + 1 ) c(a+1)(b+1) matches. So D 3 = ( c + 1 ) D 2 [ a , b ] + c ( a + 1 ) ( b + 1 ) D_{3}=(c+1)D_{2[a,b]}+c(a+1)(b+1) , where D 2 [ a , b ] = a ( b + 1 ) + b ( a + 1 ) D_{2[a, b]}=a(b+1)+b(a+1) (2.formula) , because:

This rectangles we can divide to lines with a a lenght, b + 1 b+1 times. Between this lines there are a + 1 a+1 lines with b b length. So D 2 = a ( b + 1 ) + b ( a + 1 ) D_{2}=a(b+1)+b(a+1) .

If we have a flat surface and we want to build a b 1 a*b*1 cubes for this, we need D 3 [ a , b ] D_{3[a,b]} pieces of matches, where D 3 [ a , b ] = D 3 [ a , b , c ] D 2 [ a , b ] D_{3[a,b]}=D_{3[a,b,c]}-D_{2[a,b]} (3.formula) .

If there is a protruding cuboid and we want to place a a cubes next to this, we need D 3 [ a ] = a 3 + 2 D_{3[a]}=a*3+2 (4.formula) cubes.

First time we should search the whole part of the cube root of 2020, this is 12. Now 2020 1 2 3 = 292 2020-12^3=292 cubes left. We can place 2 times 12 12 1 12*12*1 cubes to the sides of the big cube. After that 292 2 1 12 12 = 4 292-2*1*12*12=4 cubes left. But we can place this cubes next to the second 12 12 1 12*12*1 cube, because after the placing the first, the sides of the big cube are: 12, 12 and 13. Let's use the formulas:

The big cuboid: D 3 [ 12 , 12 , 13 ] D_{3[12, 12, 13]}

The 12 12 12*12 square on this side: D 3 [ 12 , 12 ] D_{3[12, 12]}

And the last 4 squares: D 3 [ 4 ] D_{3[4]}

The number of matches: D 3 [ 12 , 12 , 13 ] D_{3[12, 12, 13]} + D 3 [ 12 , 12 ] D_{3[12, 12]} + D 3 [ 4 ] = 12 ( 12 + 1 ) ( 13 + 1 ) + 12 ( 12 + 1 ) ( 13 + 1 ) + 13 ( 12 + 1 ) ( 12 + 1 ) + D 3 [ 1 , 12 , 12 ] D 2 [ 12 , 12 ] + 4 3 + 2 = 6565 + 1 ( 12 + 1 ) ( 12 + 1 ) + 12 ( 1 + 1 ) ( 12 + 1 ) + 12 ( 1 + 1 ) ( 12 + 1 ) 12 ( 12 + 1 ) 12 ( 12 + 1 ) + 14 = 6579 + 481 = 7060 D_{3[4]}=12(12+1)(13+1)+12(12+1)(13+1)+13(12+1)(12+1)+D_{3[1,12,12]}-D_{2[12,12]}+4*3+2=6565+1(12+1)(12+1)+12(1+1)(12+1)+12(1+1)(12+1)-12(12+1)-12(12+1)+14=6579+481=\boxed{7060}

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int kocka;
    cin>>kocka;
    int a=0, g=0, n=0, db, kerekit, t, tid;
    for(;g<=kocka;a++)g=pow(a+1,3);
    a--;
    n+=3*a*pow(a+1,2);
    kocka-=pow(a,3);
    int b[3]={0, 0, 0},oldal[4]={0, 0, 0, 0};
    for(int z=0;kocka!=0;z++){
        b[z]=sqrt(kocka);
        b[z]=(b[z]>a)? a:b[z];
        kocka-=pow(b[z],2);
        n+=2*b[z]*(b[z]+1)+pow((b[z]+1),2);
        oldal[0]+=oldal[z+1]=(b[z]==a)? (z*b[z]): 2*b[z];
        if(oldal[0]>=kocka&&kocka!=0){
            for(int x=1;kocka!=0;x++){
                t=max(max(oldal[1],oldal[2]), oldal[3]);
                if(oldal[1]==t) tid=1;else if(oldal[2]==t) tid=2;else tid=3;
                oldal[tid]=0;
                db=min(kocka, t);
                kocka-=db;
                kerekit =((db-1)/b[x-1])+1;
                n+= 5*kerekit+(db-kerekit)*3;
            }
        }
    }
    cout<<n;
    return 0;
}

A Former Brilliant Member - 1 year, 1 month ago

2 pending reports

Vote up reports you agree with

×

Problem Loading...

Note Loading...

Set Loading...