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

太恶了,刷了无数个WA,TLE

Posted by zyz at 2008-10-19 00:22:22 on Problem 3318
难道是我的算法有问题?

#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:
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