| 记录编号 | 
        44127 | 
        评测结果 | 
        AAAAAAAAAAAAAAAAAAAA | 
    
    
        | 题目名称 | 
        1163.数列求值 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         QhelDIV | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.007 s  | 
    
    
        | 提交时间 | 
        2012-10-16 22:03:35 | 
        内存使用 | 
        3.27 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include <fstream>
#include <memory.h>
using namespace std;
ifstream fin("sequenceb.in");
ofstream fout("sequenceb.out");
int A,B,N,ans[3],f[3][3],temp[3][3],MR[3][3]=
{
{0,0,0},
{0,0,1},
{0,1,1}
};
void Di(int pos)
{
int i,j,k;
	if(pos==1)
		return;
	Di(pos/2);
	memset(temp,0,sizeof(temp));
		for(i=1;i<=2;i++)
			for(j=1;j<=2;j++)
				for(k=1;k<=2;k++)
				{
					temp[i][j]+=f[k][j]*f[i][k];
					temp[i][j]%=7;
				}
		for(i=1;i<=2;i++)
			for(j=1;j<=2;j++)
				f[i][j]=temp[i][j];
	memset(temp,0,sizeof(temp));
	if(pos%2!=0)
	{
		for(i=1;i<=2;i++)
			for(j=1;j<=2;j++)
				for(k=1;k<=2;k++)
				{
					temp[i][j]+=MR[k][j]*f[i][k];
					temp[i][j]%=7;
				}
		for(i=1;i<=2;i++)
			for(j=1;j<=2;j++)
				f[i][j]=temp[i][j];
	}
}
int main()
{
	fin>>A>>B>>N;
	MR[1][2]=B;MR[2][2]=A;
	f[1][2]=B;f[2][2]=A;f[1][1]=MR[1][1];f[2][1]=MR[2][1];
	ans[1]=1;ans[2]=1;
	Di(N-1);
	
int temp[3]={0,0,0};
	for(int i=1;i<=2;i++)
		for(int j=1;j<=2;j++)
		{
			temp[i]+=ans[j]*f[j][i];
			temp[i]%=7;
		}
	fout<<temp[1]<<endl;
	fin.close();
	fout.close();
	return 0;
}