hdu 4686 Arc of Dream
思路:构造矩阵
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的更多相关文章
- HDU 4686 Arc of Dream (矩阵快速幂)
Arc of Dream Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Tota ...
- hdu 4686 Arc of Dream(矩阵快速幂乘法)
Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai- ...
- HDU 4686 Arc of Dream(递归矩阵加速)
标题效果:你就是给你一程了两个递推公式公式,第一个让你找到n结果项目. 注意需要占用该公式的复发和再构造矩阵. Arc of Dream Time Limit: 2000/2000 MS (Java/ ...
- HDU 4686 Arc of Dream(矩阵)
Arc of Dream [题目链接]Arc of Dream [题目类型]矩阵 &题解: 这题你做的复杂与否很大取决于你建的矩阵是什么样的,膜一发kuangbin大神的矩阵: 还有几个坑点: ...
- 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 ...
- HDU 4686 Arc of Dream(矩阵)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 思路: #include <iostream>#include <cs ...
- 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 ...
- HDU 4686 Arc of Dream 矩阵快速幂,线性同余 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=4686 当看到n为小于64位整数的数字时,就应该有个感觉,acm范畴内这应该是道矩阵快速幂 Ai,Bi的递推式题目 ...
- HDU 4686 Arc of Dream(快速幂矩阵)
题目链接 再水一发,构造啊,初始化啊...wa很多次啊.. #include <cstring> #include <cstdio> #include <string&g ...
随机推荐
- windows phone 8 开发系列(一)环境搭建
一:前奏说明 本人一名普通的neter,对新玩意有点小兴趣,之前wp7出来的时候,折腾学习过点wp7开发,后来也没怎么用到(主要对微软抛弃wp7的行为比较不爽),现在wp8已经出来一段时间了,市场上也 ...
- 无法安装程序包“MIcrosoft.Owin.Security 2.0.2”。您正在尝试将此程序包安装到某个将“.NETFramework,Version=v4.0”作为目标的项目中。
在VS2010 MVC4项目中,安装NuGet程序包Microsoft.AspNet.SignalR时出现以下错误: 原因是安装的版本是Microsoft.AspNet.SignalR 2.0.2,要 ...
- Linux下ThinkPHP网站目录权限设置
在windows上运行好好的项目,迁移到Linux上就遇到了很多问题,其中最为重要的是网站目录权限的设置,当然简单期间你可以用 命令 "chmod 777 -R you web site&q ...
- easyui菜单栏的使用
<div id="tabs" class="easyui-tabs" data-options="plain:true,fit:true,bor ...
- PySide 简易教程<三>-------动手写起来
到目前为止,已经接触的Pyside的界面元素有如下几个:QWidget.QPushButton.QLabel.本次再介绍两个tooltip和messagebox.tooltip是一个鼠标悬浮提示信息, ...
- WPF的UI布局(Layout)WPF读书笔记(第三天)
WPF的布局元素有一下几个 Grid:网格.可以自定义行和列并且通过行列的数目.行高和列宽来调整控件的布局. StackPanel:格式面板.可将包含的元素在水平方向或者竖直方向排成一条线. ...
- CentOS安装thrift
下载thrift依赖的东西 yum -y install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-dev ...
- linux下gcc编译的参数详细说明
参考网址:1 http://hi.baidu.com/zengzhaonong/item/f1f9383565fa5c302e0f8125 gcc使用方法 汇总 2 http://s99f.blog. ...
- C#位操作符
位操作符是对数据按二进制位进行运算的操作符.c#位操作符包括: 按位与 & 按位或 | 按位取反 ~ 左移 << 右移 >> 例如: 6:00000110 3:00 ...
- UML类图关系大全-转
1.关联 双向关联: C1-C2:指双方都知道对方的存在,都可以调用对方的公共属性和方法. 在GOF的设计模式书上是这样描述的:虽然在分析阶段这种关系是适用的,但我们觉得它对于描述设计模式内的类关系来 ...