Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

这真是把程序理解到一定境界了 明明很稀疏的矩阵 明明可以有强有力的优化 真正的把握程序的脉动才能写出优美的程序!

Posted by 123234345 at 2011-07-17 19:58:11 on Problem 3735
In Reply To:雁过留声——一句话的力量 Posted by:fanhqme at 2009-07-13 16:03:54
> 很普通的矩阵乘法的应用
> 
> 有一个特殊的地方:要支持+1的操作
> 我的办法是:加入一个叫“1”的猫,+1相当于把它和“1”合并
> 于是矩阵的规模变成了101*101
> 
> 交上去,tle了
> 
> 为什么呢?
> 是不应该用long long?
> 用unsighed int,wa了
> 
> 突发奇想,把
> for (int i=0;i<N;i++)for (int j=0;j<N;j++)for (int k=0;k<N;k++)
> a[i][j]+=b[i][k]*c[k][j];
> 改写为
> for (int i=0;i<N;i++)for (int j=0;j<N;j++)if (b[i][j])for (int k=0;k<N;k++)
> a[i][k]+=b[i][j]*c[j][k];
> 
> 就ac了!
> 
> 真是一句话的力量呀,可以化腐朽为神奇,化雾霭为黎明。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator