当前位置:码农谷 > 算法与程序 > HDU 3493 The Little Architect:题目解答源码

HDU 3493 The Little Architect:题目解答源码

所属学科:C++语言 - 程序控制结构 难度: 关注度:24

LY is a little architect, he likes to make all kinds of buildings with his building blocks. All the building blocks are the same cubes. Now he want to make a new building. He don’t want any floor of his building is disconnected. So sample of the building he likes and he dislikes like these:

The building he likes. The building he dislikes.      

  For example, the first building he likes because all the blocks in every line are not disconnected, while the second building he dislikes because in line 1, 3, 4, the blocks are disconnected.      
  Now LY has a question. If he has n building blocks, and how many different buildings he can build. We ensure that all the building blocks are in the same plane.      

输入描述

  There are several lines in the input. Each line is a set of input data. There is only one integer n (0 < n < 1,000,000,000) means the number of blocks buildings he has. The last line of the input is a line contains 0.

输出描述

  For each set of input, output a single line contains one integer which is the number of different buildings he can build mod 9997.

程序源码

完整的源代码如下

#include "iostream"
#include "string.h"
using namespace std;
const int mod=9997;
int f[3][3],map[3][3];
int t[3][3]={{5,-7,4},{1,0,0},{0,1,0}};
int g[4][1]={1,2,6,19},n;
void multy_2(int v[][3],int u[][3])
{
     int c[3][3];
     memset(c,0,sizeof(c));
     for(int i=0;i<3;i++)
     {
         for(int j=0;j<3;j++)
         {
              for(int k=0;k0;k=k>>1)
     {
         if(k & 1) multy_2(map,f);
         multy_2(f,f);
     }

关注微信,获得更多免费资源
关于我们   |   免责声明   |   联系我们   |   网站地图   |   HR交流群   |   学生交流群   |   教师交流群

码农谷   版权所有 © 2015-2017   湘ICP备16018319号-1