## 10743 - Blocks on Blocks

Moderator: Board moderators

ranjit
New poster
Posts: 34
Joined: Fri Jan 30, 2004 11:22 am
Location: india

### Beautiful proof

Really nice proof. Thanks for it.

CodeMaker
Experienced poster
Posts: 183
Joined: Thu Nov 11, 2004 12:35 pm
Hi Cho, I am really interesed about your proof, but unfortunately I can't open the file format you have used. do you have any other file format like .pdf or plz mention what software will support the file, I will collect it then. Jalal : AIUB SPARKS

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong
My signature:
We can learn much more in discussion than reading source code.
• I HATE testing account.
• Don't send me source code for debug.

Cho
A great helper
Posts: 274
Joined: Wed Oct 20, 2004 11:51 pm
Location: Hong Kong
CodeMaker wrote:do you have any other file format like .pdf
here is the pdf format: 10743.pdf

Angeh
Experienced poster
Posts: 108
Joined: Sat Aug 08, 2009 2:53 pm

### Re: 10743 - Blocks on Blocks

hi alll ....
can somebody help
it doesnt work for n==999 ... returns negative number .....
why???????!!!!!!

Code: Select all

#include<iostream>
using namespace std;
const long long Mode=10000;
#define FOR(i,n) for(int i=0;i<n;++i)
long long matrix={0,0,4,1,0,-7,0,1,5},result,temp;
void power(int n ){
if(n==1) FOR(r,3)FOR(c,3)result[r][c]=matrix[r][c];
else if(n%2==1){
power(n/2);
FOR(r,3)FOR(c,3)temp[r][c]=0;
FOR(r,3)FOR(c,3)FOR(i,3)temp[r][c] = (temp[r][c]+result[r][i]*result[i][c])%Mode ;

FOR(r,3)FOR(c,3)result[r][c]=0;
FOR(r,3)FOR(c,3)FOR(i,3)result[r][c] = (result[r][c] + temp[r][i]*matrix[i][c])%Mode;
}
else {
power(n/2);
FOR(r,3)FOR(c,3)temp[r][c]=0;
FOR(r,3)FOR(c,3)FOR(i,3)temp[r][c] = (temp[r][c] + result[r][i]*result[i][c] )%Mode;

FOR(r,3)FOR(c,3)result[r][c]=temp[r][c];
}
return ;
}
int main(){
//freopen("in.txt","r",stdin);
int cas,n,res;
scanf("%d",&cas);
for(int ca=0;ca<cas;++ca){
scanf("%d",&n);
if(n==1)res=1;
else if(n==2)res=2;
else if(n==3)res=6;
else if(n==4)res=19;
else {
power(n-4);
res= ( result*2 + result*6 + result*19 )%Mode;
}
if(n<9)printf("Case %d: %d\n",ca+1,res);
else printf("Case %d: %04d\n",ca+1,res);
}
return 0;
}
>>>>>>>>> A2
Beliefs are not facts, believe what you need to believe;)

dull_jester
New poster
Posts: 17
Joined: Fri Oct 21, 2016 12:58 pm