记录编号 |
281158 |
评测结果 |
AAAAAAAAAA |
题目名称 |
数学序列 |
最终得分 |
100 |
用户昵称 |
NewBee |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.004 s |
提交时间 |
2016-07-11 08:41:54 |
内存使用 |
0.29 MiB |
显示代码纯文本
- #include<cstdio>
- #define Cu fclose(stdin);fclose(stdout);return 0;
- #define Begin freopen("number1.in","r",stdin);freopen("number1.out","w",stdout);chul();Cu;
- using namespace std;
- //designed by New_Beeؼ
- int a,b,n;
- struct op{
- int A[3][3];
- void init(int a,int b,int c,int d){
- A[1][1]=a;
- A[2][1]=b;
- A[1][2]=c;
- A[2][2]=d;
- }
- op operator *(const op &b)const{
- op c;
- for(int i=1;i<3;i++){
- for(int j=1;j<3;j++){
- c.A[i][j]=0;
- for(int k=1;k<3;k++){
- c.A[i][j]+=((A[i][k]*b.A[k][j])%7);
- c.A[i][j]%=7;
- }
- }
- }
- return c;
- }
- };
- op qpow(op x,int t){
- op an;
- an.init(1,0,0,1);
- for(;t;t>>=1){
- if(t&1)an=an*x;x=x*x;
- }return an;
- }
- void clean(){
- op ans;
- ans.init(a,b,1,0);
- ans=qpow(ans,n-2);
- printf("%d\n",(ans.A[1][1]+ans.A[2][1])%7);
- }
- void chul(){
- while(scanf("%d%d%d",&a,&b,&n)!=EOF){
- if(n==1){
- printf("1");
- continue;
- }
- clean();
- }
- }
- int main(){
- Begin;
- }