FZU Problem 1692 Key problem(循环矩阵)
来源:互联网 发布:mac子弹头rebel 编辑:程序博客网 时间:2024/06/04 19:54
循环矩阵,这里有讲解:http://wenku.baidu.com/link?url=zcJ-sxrj0QDqzz8xCnHTnB7gxjoNRyOZzS4_4ZA22c8Bs9inYn6vVkqTVr_w-riLa8oRnYA9SRcCZ9f4UciCUNGeNAG4dCGclYRPS18YLGa
推出第一层下面根据性质就可以得到。
Problem 1692 Key problem
Accept: 144 Submit: 663
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Input
Output
Each case separated by a space. See sample.
Sample Input
1 3 2 3 4 10000 1 2 3
Sample Output
120 133 131
Source
FOJ月赛-2009年3月--- Coral#include <set>#include <map>#include <queue>#include <math.h>#include <vector>#include <string>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <algorithm>#define eps 1e-8#define pi acos(-1.0)#define LL __int64using namespace std;const int maxn = 110;LL a[maxn], b[maxn], f[maxn];LL mod, n;void mul(LL a[], LL b[]){ LL c[maxn]; memset(c, 0, sizeof(c)); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) c[i] = (a[j]*b[(i-j+n)%n]+c[i])%mod; memcpy(a, c, sizeof(c));}void pow_mod(LL a[], LL b){ LL c[maxn]; memset(c, 0, sizeof(c)); c[0] = 1LL; while(b) { if(b&1) mul(c, a); mul(a, a); b >>= 1; } memcpy(a, c, sizeof(c));}int main(){ int T; cin>>T; LL m, l, r; while(T--) { cin>>n>>m>>l>>r>>mod; for(int i = 0;i < n;i++) cin>>a[i]; memset(f, 0, sizeof(f)); f[0] = 1; f[1] = r; f[n-1]=l; pow_mod(f, m); LL ans[maxn]; for(int i = 0; i < n; i++) { ans[i] = 0; for(int j = 0;j < n;j++) ans[i] = (ans[i]+a[j]*f[(i-j+n)%n])%mod; } cout<<ans[0]; for(int i = 1; i < n; i++) cout<<" "<<ans[i]; cout<<endl; } return 0;}
0 0
- FZU Problem 1692 Key problem(循环矩阵)
- fzu 1692 Key problem 循环矩阵
- FZU 1692 Key problem(循环矩阵)
- FZU - 1692 Key problem 矩阵快速幂
- FZU 1692 Key problem
- FZU 1692 Key problem
- fzu 1692 Key problem(循环同构矩阵o(n^2)优化乘法)
- FZU 1692 Key problem(构造矩阵+矩阵快速幂)
- 解题报告:FZU1692 Key problem 循环矩阵快速幂
- Fzoj 1692 Problem 1692 Key problem [特殊矩阵的n^2复杂度求矩阵乘法]
- FOJ 1692 Key problem
- FZU Problem 2104 Floor problem
- FZU problem 1985 LCP Problem
- FZU Problem 2198 快来快来数一数(矩阵快速幂 卡常数 +优化)
- hdu 4291 A Short problem 矩阵+循环
- fzu problem 1013 rpgame
- FZU Problem 2110 Star
- FZU Problem 2054 拳王
- yii的邮件发送扩展的使用
- 人才供应链管理模式
- 新一代Windows Server技术预览版已发布
- hdu1435 稳定婚姻问题
- do not use printf without %s to print a string
- FZU Problem 1692 Key problem(循环矩阵)
- 为了人本身,为了人自身的发展
- 数据挖掘中所需的概率论与数理统计知识、上
- 就如戴尔在供应链管理上的优秀
- Android中focusable属性的妙用——底层按钮的实现
- SDUTOJ 1351 Max Sum
- java web中实现同一帐号同一时间只能一个地点登陆(类似QQ登录的功能)
- POJ1236 强连通 (缩点后度数的应用)
- Linux系统调用--getpid/getppid函数详解