/* by Raymond Le Grand */ #include #define SIZE 100 using namespace std; double total; double tbl[SIZE][SIZE]; bool ispossible(int num,int maxnum,int level){ //does adding the num make it greater than total? if (num==4) num=1; return (num<=maxnum); } void digitizer(int spaces,int maxnum, int level){ int nmax; double count; level++; count=total; if (tbl[spaces][maxnum]==0){ for(int i=1;i<=4;i++){ nmax=maxnum-i; if (i==4) nmax=maxnum-1; if (ispossible(i,maxnum,level)){ if (nmax==0){ total++; //because we know we can add i, but not anything more }else{ digitizer(spaces-1,nmax,level); //if( level==1)return 0; } } } //before return, save results of this calculation tbl[spaces][maxnum]=total-count; }else{ total+=tbl[spaces][maxnum]; } } int main(){ int num; while(true){ cin>>num; if (cin.eof()==true)break; for (int i=0;i0){ cout<