记录编号 |
280816 |
评测结果 |
AAAAAAAAAA |
题目名称 |
数学序列 |
最终得分 |
100 |
用户昵称 |
Hzoi_chairman |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.000 s |
提交时间 |
2016-07-10 18:14:54 |
内存使用 |
0.00 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int read()
{
char ch;
int x,f=1;
while(ch=getchar(),!isdigit(ch))
{
if(ch=='-')f=-1;
if(ch==EOF)return -1;
}
x=ch-48;
while(ch=getchar(),isdigit(ch))x=x*10+ch-48;
return x*f;
}
struct mat
{
int n,m,a[5][5];
void clear()
{
n=0,m=0;memset(a,0,sizeof(a));
}
mat operator * (const mat & x)
{
mat tmp;tmp.clear();
tmp.n=n;tmp.m=x.m;
for(int i=1;i<=tmp.n;i++)
for(int j=1;j<=tmp.m;j++)
for(int k=1;k<=m;k++)
tmp.a[i][j]+=a[i][k]*x.a[k][j],tmp.a[i][j]%=7;
return tmp;
}
};
int init()
{
freopen("number1.in","r",stdin);
freopen("number1.out","w",stdout);
int a,b,n;
while(a=read(),a!=-1)
{
b=read(),n=read();
n -= 2;
mat first;first.clear();
first = (mat){1, 2, {{0},{0,1,1}}};
mat x;x.clear();
x = (mat){2, 2, {{0},{0,a,1},{0,b,0}}};
for(int i=1; i<=n; i<<=1, x=x*x)
if(n&i) first = first*x;
printf("%d\n", first.a[1][1]);
}
fclose(stdin);
fclose(stdout);
return 0;
}
int i=init();
int main()
{
}