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

Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 419    Accepted Submission(s): 148 Problem Description An Arc of Dream is a curve defined by following function:wherea0 = A0ai = ai-1…
Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai-*AX+AY b0 = B0 bi = bi-*BX+BY What ,,,?   Input There are multiple test cases. Process to the End of File. Each test nonnegative integers as follows:…
标题效果:你就是给你一程了两个递推公式公式,第一个让你找到n结果项目. 注意需要占用该公式的复发和再构造矩阵. Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2092    Accepted Submission(s): 664 Problem Description An Arc of Dream is a…
Arc of Dream [题目链接]Arc of Dream [题目类型]矩阵 &题解: 这题你做的复杂与否很大取决于你建的矩阵是什么样的,膜一发kuangbin大神的矩阵: 还有几个坑点:当n是0 输出0;建矩阵时是相乘的一定要取模M,因为如果不取模最大的情况是1e9*2e9*2e9,爆long long 这块坑了我好长时间. &代码: #include <cstdio> #include <bitset> #include <iostream> #…
Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description An Arc of Dream is a curve defined by following function:wherea0 = A0ai = ai-1*AX+…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 思路: #include <iostream>#include <cstdio>#include <string.h>#include <algorithm>#include <cmath>#include <vector>#include <queue>#include <set>#include…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 其中a0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BY 最后的结果mod 1,000,000,007 n<=10^18. 分析:ai*bi=(ai-1 *ax+ay)*(bi-1 *bx+by) =(ai-1 * bi-1 *ax*bx)+(ai-1 *ax*by)+(bi-1 *bx*ay)+(ay*by) 设p=ax*bx,  q=ax*by, …
http://acm.hdu.edu.cn/showproblem.php?pid=4686 当看到n为小于64位整数的数字时,就应该有个感觉,acm范畴内这应该是道矩阵快速幂 Ai,Bi的递推式题目已经给出, Ai*Bi=Ax*Bx*(Ai-1*Bi-1)+Ax*By*Ai-1+Bx*Ay*Bi-1+Ay*By AoD(n)=AoD(n-1)+AiBi 构造向量I{AoD(i-1),Ai*Bi,Ai,Bi,1} 初始向量为I0={0,A0*B0,A0,B0,1} 构造矩阵A{ 1,0,0,0,…
题目链接 再水一发,构造啊,初始化啊...wa很多次啊.. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; #define MOD 1000000007 #define…
思路:构造矩阵 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 10000000…
A.mat[0][0] = 1, A.mat[0][1] = 1, A.mat[0][2] = 0, A.mat[0][3] = 0, A.mat[0][4] = 0; A.mat[1][0] = 0, A.mat[1][1] = AX*BX%Mod, A.mat[1][2] = AX*BY%Mod, A.mat[1][3] = AY*BX%Mod, A.mat[1][4] = AY*BY%Mod; A.mat[2][0] = 0, A.mat[2][1] = 0, A.mat[2][2] =…
矩阵高速幂: 依据关系够建矩阵 , 高速幂解决. Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2164    Accepted Submission(s): 680 Problem Description An Arc of Dream is a curve defined by following fun…
构造矩阵如下: Ai*bi AX*BX AX*BY AY*BX AY*BY 0 a(i-1)*b(i-1) Ai 0 AX 0 AY 0 a(i-1) Bi 0 0 BX BY 0 b(i-1) 1 0 0 0 1 0 1 Sum(i) AX*BX AX*BY AY*BX AY*BY 1 sum(i-1) Sum(i) 表示i项和,sum(i)=sum(i-1)+ai*bi; 求第n次的结果,直接对矩阵作n-1次,利用矩阵快速幂,时间复杂度为10*logn~logn 注意取模爆范围和对n=0特判…
题意:略 构造出矩阵就行了 |   AX   0    AXBY   AXBY       0  |                                                                       |   0     BX    AYBX    AYBX    0  | {a[i-1]   b[i-1]   a[i-1]*b[i-1]  AoD[i-1]  1}*        |   0     0      AXBX      AXBX   0  …
Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 4246    Accepted Submission(s): 1332 Problem Description An Arc of Dream is a curve defined by following function: wherea0 = A0ai = a…
Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2010    Accepted Submission(s): 643 Problem Description An Arc of Dream is a curve defined by following function:wherea0 = A0ai = ai-…
Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 932    Accepted Submission(s): 322 Problem Description An Arc of Dream is a curve defined by following function:where a0 = A0 ai = a…
题目链接:https://vjudge.net/problem/HDU-4686 Arc of Dream Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 5506    Accepted Submission(s): 1713 Problem Description An Arc of Dream is a curve defined…
An Arc of Dream is a curve defined by following function: where a 0 = A0 a i = a i-1*AX+AY b 0 = B0 b i = b i-1*BX+BY What is the value of AoD(N) modulo 1,000,000,007? InputThere are multiple test cases. Process to the End of File. Each test case con…
Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 3354    Accepted Submission(s): 1055 Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai-1*AX+AY…
由式子的性质发现都是线性的,考虑构造矩阵,先有式子,a[i] = ax * a[i-1] + ay; b[i] = bx*b[i-1] +by; a[i]*b[i] = ax*bx*a[i-1]*b[i-1] + ax*by*a[i-1] + bx*ay*b[i-1]+ay*by; s[i] = s[i-1] + a[i-1]*b[i-1]; 由此得到递推式 :设矩阵A= ax 0 0 0 ay 0 bx 0 0 by ax*by bx*ay ax*bx 0 ay*by 0 0 1 1 0 0…
link: http://acm.hdu.edu.cn/showproblem.php?pid=4686 构造出来的矩阵是这样的:根据题目的ai * bi = ……,可以发现 矩阵1 * 矩阵3 = 矩阵2.然后就是矩阵快速幂了. 1 1 ai bi ai*bi Si 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 ai+1 bi+1 ai+1*bi+1 Si+1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 1 AY…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 因为ai = ai-1*AX+AY ,bi = bi-1*BX+BY ,那么ai*bi=AX*BX*A*ai-1*bi-1+AX*BY*ai-1+BX*AY*bi-1+AY*BYAY.令Sn为ai*bi前n项的和,Sn=Sn-1 + an*bn,因此我们可以构造一个如下的转移矩阵: 然后矩阵乘法优化就可以了... 注意此题n=0的情况! 其实矩阵大小只要5就可以了,那几个常数项可以合并到一列.…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4686 题目大意: 已知a0=A0, ai=Ax*ai-1+Ay; b0=B0, bi=Bx*bi-1+By; 求∑ai*bi(i=0-->n-1). n不超过1018,A0,Ax,Ay,B0,Bx,BY不超过2*109. 题目分析: 因为n很大,不可能用递推来做,这个时候就想到了矩阵的方法.构造了好几个满足要求的,但都是仅仅满足ai或者bi的,最后才发现,把ai*bi按递推式展开, ai*bi=A…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题目意思:给出一个n,算这个式子,给出A0,B0,AX,AY,然后存在以下的递推关系. a0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BY 构造矩阵的思路先算ai,bi,然后算Aod(i),然后再求和,说明这个一定是一个4*4的矩阵,我们可以构造以下系数矩阵(构造矩阵技巧可能会准备专门总结一下): [    1 ,          0 ,    0 ,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1400 题目意思:给出一个h * w的 大 矩形,需要用 1 * 2 的砖块去填充这个大矩形,问填充的方案数是多少. 这题参考这里的: http://www.informatik.uni-ulm.de/acm/Locals/2000/solution/dream.c 把每一列的方格压缩为二进制编码,搜索上一列到当前列的状态转化是否能够成功.对于每一个位置,有3种放置方法:竖直.水平.不放 对每个方格,…
HDU - 1400 思路: 轮廓线dp入门题 #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp make_pair #define pb push_back #define ls rt<<1, l, m #define rs rt<<1|1, m+1…
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - HDU4686 题意概括 a0 = A0 ai = ai-1*AX+AY b0 = B0 bi = bi-1*BX+BY 求AoD(n) n=0时答案为0!!!! 题解 具体的矩阵构建思路指导可以参考例题链接. 这里仅提供运算过程. Ai=Ai-1*AX+AY Bi=Bi-1*BX+BY AiBi=(Ai-1*AX+AY)(Bi-1*BX+BY)    =AX*BX*Ai-1*Bi-1+AX*BY*Ai-1…
题意:求\(\sum_{i=0}^{n-1}a_ib_i\) 其中,\(a_i=A_xa_{i-1}+A_y,b_i=B_xb_{i-1}+B_y\) 构造矩阵分别维护\(a_ib_i,a_i,b_i,A_yB_y,A_y,B_y,S_i\) \[ \begin{bmatrix} a_ib_i \\ a_i \\ bi \\ A_yB_y \\ A_y \\ B_y \\ S_i\\ \end{bmatrix} = \begin{bmatrix} A_xB_x & A_xB_y & A_y…
再不能直视这道题,换INT64就过了....... 同样可以使用矩阵的方法.构造1*5的 D[N],a[n],b[n],a[n]*b[n],1 接着你应该就会了. #include <iostream> #include <cstdio> #include <algorithm> #define LL __int64 using namespace std; const LL Mod=1000000007; struct Matrax{ LL m[6][6]; }; L…