怎么做,拜托了(&#3233次列车;ω&#3233次列车;)

Custom Home Remodeling & Roofing, Inc. | Your #1 Roofers at – (866)-923-3233
Custom Home Remodeling & Roofing has been in business for almost 10 years now and is founded on the pillars of trust, honesty and professionalism in an industry that is fraught with a lack of it!
Call us at 866-923-3233 to hire a reliable company with experience and endless capabilities!
Find Us – Southern California
Our services:
Residential Roof Installations
Commercial Roof Installations
Maintenance and Repair
Roofing Inspections
And much more!!
As the seasons change and time passes by, the exterior of your home will be affected by the elements. Especially your roof. Are you already noticing that something might be wrong with it? It’s your lucky day, because CHR Roofing is here to make everything right. We are Southern CA based roofing contractor that knows what your residence needs. From shingle work to complete roof installations, we do it all! For more than 10 years, our licensed, bonded, and insured company has helped people in the area. If you are looking for high quality CHR Roofing services, you have come to the right place!
CHR Roofing
Serving All of Southern California
Phone: (866)-923-3233
What sets CHR Roofing apart from your regular roofing company is not only the variety of our roofing services, but our impeccable quality control protocols. After all, you wish to have a roof that will withstand rain, wind, and hale. In order for your roof to be as durable and long lasting as possible, our specialists always make an extra effort and use only the finest products and materials available on the market. Give us the chance to show you what our roofing professionals can do, and you will be more than impressed!
If you are in need of a roofer who can help you out, do not search for amateurs. There are many people that claim that they can do a good CHR R however, results delivered by unqualified personnel are always disappointing. If you wish to benefit from professional roofing repair services, then our roofing professionals will gladly help you out. If you are worried about your checkbook, you don’t need to be. All of our services come at reasonable prices! For additional information on our roofing services, contact us today!
“Check out our work in this issue of DREAM HOMES of ORANGE COUNTY-LOOK FOR US ON PAGE 63!”
Click here to Visit:
“CHR Sponsors a local grade school”
St’ Mary’s Golf Classic.
Outstanding roofing solutions at – (866)-923-3233!
Follow us on:
Contact us:
Leave us an e-mail
Thumbtack Award> poj 3233 Matrix Power Series 矩阵高速幂
poj 3233 Matrix Power Series 矩阵高速幂
pepterpan & &
发布时间: & &
浏览:13 & &
回复:0 & &
悬赏:0.0希赛币
poj 3233 Matrix Power Series 矩阵快速幂
  /*愧疚了,好久没写什么有意思的题了。
这道基于二分的矩阵连乘,方法很经典。
求幂二分,求和再二分。经典。
求幂的时候,若奇数,A^n=A^(n/2)*A^(n/2)*A.
偶数时 A^n=A^(n/2)*A^(n/2)。
求和的时候,若为奇数,A^1+A^2+...+A^(2*m+1)=(A^1+...+A^m)+(A^1+...+A^m)*A^m*A,
A^1+A^2+...+A^(2*m+1)=(A^1+...+A^m)+(A^1+...+A^m)*A^m。
奇数的时候,构造0,1单位矩阵。
对奇数进行特判。
memcpy(a,b,sizeof(int)*N*N);
切记memcpy的赋值范围。之前因为太小,答案一直错误。*/
#include &stdio.h&
#include &cstring&
int n,m,k;
const int N=31;
int ans[N][N],A[N][N];
void add(int a[][N],int b[][N])
for(int i=0; i&n; i++)
for(int j=0; j&n; j++)
a[i][j]+=b[i][j];
if(a[i][j]&=m) a[i][j]%=m;
void mul(int a[][N],int b[][N])
int tmp[N][N];
for(int i=0; i&n; i++)
for(int j=0; j&n; j++)
tmp[i][j]=0;
for(int k=0; k&n; k++)
tmp[i][j]+=a[i][k]*b[k][j];
if(tmp[i][j]&=m) tmp[i][j]%=m;
memcpy(a,tmp,sizeof(tmp));
void pow(int a[][N],int b[][N],int x)
int tmp[N][N];
memcpy(tmp,b,sizeof(int)*N*N);
for(int i=0; i&n; i++)
for(int j=0; j&n; j++)
if(i==j) a[i][j]=1;
else a[i][j]=0;
if(x&1)//最后的结果存在数组a中,因为最后x比为1,符合条件,自己模拟一遍则易知.
mul(a,tmp);
mul(tmp,tmp);
void mat_sum(int a[][N],int b[][N],int x)
int c[N][N],d[N][N];
memset(a,0,sizeof(int)*N*N);
memcpy(a,b,sizeof(int)*N*N);
mat_sum(a,b,x$>$1);
pow(c,b,x$>$1);
memcpy(d,a,sizeof(int)*N*N);
int main()
while(scanf(&%d%d%d&,&n,&k,&m)==3)
for(int i=0; i&n; i++)
for(int j=0; j&n; j++)
scanf(&%d&,&A[i][j]);
mat_sum(ans,A,k);
for(int i=0; i&n; i++)
printf(&%d&,ans[i][0]);
for(int j=1; j&n; j++)
if(j&n-1) printf(& %d&,ans[i][j]);
else printf(& %d\n&,ans[i][j]);
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&}

我要回帖

更多关于 poj3233 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信