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 |
太恶了,刷了无数个WA,TLE难道是我的算法有问题? #include<iostream> #include<stdio.h> #include<stdlib.h> #include<time.h> using namespace std; const int MAXN = 505; int n; long long A[MAXN][MAXN], B[MAXN][MAXN], C[MAXN][MAXN]; int main(){ scanf("%d", &n); for(int i=0; i<n; i++){ for(int j=0; j<n; j++) scanf("%lld", &A[i][j]); } for(int i=0; i<n; i++){ for(int j=0; j<n; j++) scanf("%lld", &B[i][j]); } for(int i=0; i<n; i++){ for(int j=0; j<n; j++) scanf("%lld", &C[i][j]); } int _n = n*200; bool yes = true; srand( (unsigned)time( NULL ) ); while(_n-->0){ int x = ((double)rand()/(double)RAND_MAX)*n*n; int y = x%n; x = x/n; long long _t = 0; for(int i=0; i<n; i++) _t += A[x][i]*B[i][y]; if(C[x][y]!=_t) {yes=false; break;} } if(yes) printf("YES\n"); else printf("NO\n"); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator