暑期9_15队内练习赛 B题 大数取模+矩阵快速幂

题目大意:求sin(n!*ln(n)*f[n]%2012)的结果,n<=10^9,f[n]是斐波那契数列的第n项

思路:哎~~菜菜菜啊~~却不是我的菜~~n!至少到2012都不用求后面的啦~~因为取余都为0了~~我还在傻乎乎的用矩阵求快速幂·~呜呜~~菜菜菜啊~~

AC program:(暴力无优化代码:没有优化2012后都为0的情况)

#include
#include
#include
#include
#include
using namespace std;
int aa[2015];
int f[1000005];
int sum;
struct node
{
  int a,b,c,d;       
}fsum,gg;

node ju(node aaa, node bbb)
{
  node ccc;
  ccc.a=(aaa.a*bbb.a)%2012+(aaa.b*bbb.c)%2012;
  ccc.b=(aaa.a*bbb.b)%2012+(aaa.b*bbb.d)%2012;
  ccc.c=(aaa.c*bbb.a)%2012+(aaa.d*bbb.c)%2012;
  ccc.d=(aaa.c*bbb.b)%2012+(aaa.d*bbb.d)%2012;
  //cout<<"ab cd "<=1)
        {
          for(int i=1;i<=2012;i++)
          {
                   
                 sum=  (aa[2012]* (tmp%2012))%2012;    
          }     
        }
   int kg=n%2012;
    if(kg!=0)
    {
      
        sum=sum*aa[kg];       
             
    }

           int ttt=(int)log((double)n);
                                         //cout<<"ttt "<


 

你可能感兴趣的:(数学----初等数论,优化,c)