Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:我真差劲,用概率算法还TLE, 哪位高手帮一下我?In Reply To:我真差劲,用概率算法还TLE, 哪位高手帮一下我? Posted by:200593141 at 2007-08-06 09:41:11 > #include<iostream> > #include<memory> > #include<cstdlib> > using namespace std ; > > int MatrexA[500][500] , MatrexB[500][500], MatrexC[500][500] ; > > void main() > { > int Nums ; > int item , jtem ; > int XA[500], XB[500], XAB[500], XC[500] ; > > srand(500) ; > for( item = 0; item < 500; item++ ) > XB[item] = rand() % 10 + 1; > > while( cin >> Nums ) > { > for( item = 0; item < Nums; item++ ) > for( jtem = 0; jtem < Nums; jtem++ ) > cin >> MatrexA[item][jtem] ; > > for( item = 0; item < Nums; item++ ) > for( jtem = 0; jtem < Nums; jtem++ ) > cin >> MatrexB[item][jtem] ; > > for( item = 0; item < Nums; item++ ) > for( jtem = 0; jtem < Nums; jtem++ ) > cin >> MatrexC[item][jtem] ; > > memset( XA, 0, sizeof(int) * Nums ) ; > memset( XAB, 0, sizeof(int) * Nums ) ; > memset( XC, 0, sizeof(int) * Nums ) ; > > for( item = 0; item < Nums; item++ ) > for( jtem = 0; jtem < Nums; jtem++ ) > XA[item] += MatrexB[item][jtem] * XB[jtem] ; > > for( item = 0; item < Nums ; item++ ) > { > for( jtem = 0; jtem < Nums; jtem++ ) > { > XC[item] += MatrexC[item][jtem] * XB[jtem] ; > XAB[item] += MatrexA[item][jtem] * XA[jtem] ; > } > > if( XAB[item] != XC[item] ) > { > cout << "NO\n" ; > break ; > } > } > > if( item == Nums ) > cout << "YES\n" ; > } > } 我的也超了,而且我把它换成用概率取单个数进行判断居然也显示超时,5000次都超,想不通! Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator