记录编号 281158 评测结果 AAAAAAAAAA
题目名称 数学序列 最终得分 100
用户昵称 GravatarNewBee 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2016-07-11 08:41:54 内存使用 0.29 MiB
显示代码纯文本
  1. #include<cstdio>
  2. #define Cu fclose(stdin);fclose(stdout);return 0;
  3. #define Begin freopen("number1.in","r",stdin);freopen("number1.out","w",stdout);chul();Cu;
  4. using namespace std;
  5. //designed by New_Beeؼ
  6. int a,b,n;
  7. struct op{
  8. int A[3][3];
  9. void init(int a,int b,int c,int d){
  10. A[1][1]=a;
  11. A[2][1]=b;
  12. A[1][2]=c;
  13. A[2][2]=d;
  14. }
  15. op operator *(const op &b)const{
  16. op c;
  17. for(int i=1;i<3;i++){
  18. for(int j=1;j<3;j++){
  19. c.A[i][j]=0;
  20. for(int k=1;k<3;k++){
  21. c.A[i][j]+=((A[i][k]*b.A[k][j])%7);
  22. c.A[i][j]%=7;
  23. }
  24. }
  25. }
  26. return c;
  27. }
  28. };
  29. op qpow(op x,int t){
  30. op an;
  31. an.init(1,0,0,1);
  32. for(;t;t>>=1){
  33. if(t&1)an=an*x;x=x*x;
  34. }return an;
  35. }
  36. void clean(){
  37. op ans;
  38. ans.init(a,b,1,0);
  39. ans=qpow(ans,n-2);
  40. printf("%d\n",(ans.A[1][1]+ans.A[2][1])%7);
  41. }
  42. void chul(){
  43. while(scanf("%d%d%d",&a,&b,&n)!=EOF){
  44. if(n==1){
  45. printf("1");
  46. continue;
  47. }
  48. clean();
  49. }
  50. }
  51. int main(){
  52. Begin;
  53. }