思路:构造矩阵

a[i]*b[i]=ax*bx*a[i-1]*b[i-1]+ax*by*a[i-1]+ay*bx*b[i-1]+ay*by

代码如下:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#define ll __int64
#define mod 1000000007
#define phi 1000000006
using namespace std;
struct ma
{
ll a[][];
};
ma mul(ma a,ma b)
{
ma ans;
for(int i=;i<;i++)
for(int j=;j<;j++){
ans.a[i][j]=;
for(int k=;k<;k++)
if(a.a[i][k]&&b.a[k][j])
ans.a[i][j]=(ans.a[i][j]+a.a[i][k]*b.a[k][j])%mod;
ans.a[i][j]%=mod;
}
return ans;
}
ma pow(ma a,ll n,ma ans)
{
while(n){
if(n&) ans=mul(ans,a);
n>>=;
a=mul(a,a);
}
return ans;
}
int main()
{
ll n,an,s,ab,a,b;
ll a0,b0,ax,ay,bx,by;
ma p,ans,re;
for(int i=;i<;i++)
for(int j=;j<;j++){
p.a[i][j]=;
ans.a[i][j]=;
}
p.a[][]=p.a[][]=p.a[][]=;
while(scanf("%I64d",&n)!=EOF){
scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&a0,&ax,&ay,&b0,&bx,&by);
p.a[][]=(ax*bx)%mod;p.a[][]=(ax*by)%mod;
p.a[][]=(ay*bx)%mod;p.a[][]=(ay*by)%mod;
p.a[][]=bx%mod;p.a[][]=by%mod;
p.a[][]=ax%mod;p.a[][]=ay%mod;
ans.a[][]=a0*b0%mod;ans.a[][]=a0%mod;
ans.a[][]=b0%mod;ans.a[][]=;
re=pow(p,n,ans);
printf("%I64d\n",re.a[][]%mod);
}
return ;
}

hdu 4686 Arc of Dream的更多相关文章

  1. HDU 4686 Arc of Dream (矩阵快速幂)

    Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  2. hdu 4686 Arc of Dream(矩阵快速幂乘法)

    Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai- ...

  3. HDU 4686 Arc of Dream(递归矩阵加速)

    标题效果:你就是给你一程了两个递推公式公式,第一个让你找到n结果项目. 注意需要占用该公式的复发和再构造矩阵. Arc of Dream Time Limit: 2000/2000 MS (Java/ ...

  4. HDU 4686 Arc of Dream(矩阵)

    Arc of Dream [题目链接]Arc of Dream [题目类型]矩阵 &题解: 这题你做的复杂与否很大取决于你建的矩阵是什么样的,膜一发kuangbin大神的矩阵: 还有几个坑点: ...

  5. HDU 4686 Arc of Dream (2013多校9 1001 题,矩阵)

    Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  6. HDU 4686 Arc of Dream(矩阵)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 思路: #include <iostream>#include <cs ...

  7. hdu 4686 Arc of Dream(矩阵快速幂)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 其中a0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BY ...

  8. HDU 4686 Arc of Dream 矩阵快速幂,线性同余 难度:1

    http://acm.hdu.edu.cn/showproblem.php?pid=4686 当看到n为小于64位整数的数字时,就应该有个感觉,acm范畴内这应该是道矩阵快速幂 Ai,Bi的递推式题目 ...

  9. HDU 4686 Arc of Dream(快速幂矩阵)

    题目链接 再水一发,构造啊,初始化啊...wa很多次啊.. #include <cstring> #include <cstdio> #include <string&g ...

随机推荐

  1. iOS开发零基础教程之生成git所需的SSH keys

    在我们github看到了一个不错的第三方库时,可能我们想把他git clone到本地,我们需要复制他的SSH URL,如下图: 复制完地址之后,我们需要打开终端,然后输入命令: git clone + ...

  2. c++11:copy_n

    copy_n: Copies exactly count values from the range beginning at first to the range beginning at resu ...

  3. AJAX 跨域 :Access-Control-Allow-Origin

    在一个项目上想用NodeJS,在前端的JS(http://localhost/xxx)中ajax访问后端RestAPI(http://localhost:3000/….)时(Chrome)报错: XM ...

  4. [react native] Error loading page

    如上图显示的错误,解决方法如下: 在react native ios项目的info.plist文件中,新增一个属性. 在Info.plist中添加NSAppTransportSecurity类型Dic ...

  5. jquery中简易tab切换

    <!doctype html> <html> <head> <title>test</title> <meta content=&qu ...

  6. FAN_int2ExcelColChar functions

    static void FAN_int2ExcelColChar(Args _args) { Dialog dlg = new dialog("please enter int number ...

  7. Spark 大数据平台

    Apache Spark is an open source cluster computing system that aims to make data analytics fast - both ...

  8. 基于WCF的API实现

    本文程序基于VS2013.EF6.1.WCF WCF有2种方式,一是SOAP,一种是Restful 由于程序是基于PCL(可移植类库)的,所以不能用直接引入WCF服务的方式 网上的Restful方式的 ...

  9. 介绍一下linux的文件系统

    (1)/bin:该目录用于存放用户命令. 目录 /usr/bin 中也存放了一些用户命令.(2)/sbin:该目录用于存放许多系统命令,例如 shutdown.目录 /usr/bin 中也包括了许多系 ...

  10. Python之回调魔法

    Python中魔法(前后又下划线)会在对象的生命周期被回调. 借助这种回调, 可以实现AOP或者拦截器的思想. 在Python语言中提供了类似于C++的运算符重在功能:一下为Python运算符重在调用 ...