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

确实是个token的水题!

Posted by KatrineYang at 2016-08-30 21:47:48 on Problem 1296
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int L;
int token[404][404];
int token_[404][404];

int main() {
	while(scanf("%d", &L) > 0){
		if(L == 0) break;
		for(int i = 0; i < L; i++)
			for(int j = 0; j < L; j++)
				scanf("%d", &token[i][j]);
		for(int i = 0; i < L; i++){
			for(int j = 0; j < L; j++)
				scanf("%d", &token_[i][j]);
		}
		if(L == 1){
			if(abs(0.0+token[0][0]-token_[0][0]) < 100.5){
				printf("100.00\n");
			}
			else printf("0.00\n");
			continue;
		}
		int start[4][2] = {0};
		start[1][1] = start[2][0] = start[3][0] = start[3][1] = L-1;
		int maxToken = 0;
		for(int i = 0; i < 4; i++){
			int startX = start[i][0], startY = start[i][1];
			int dirX, dirY;
			if(startX == 0) dirX = 1;
			else dirX = -1;
			if(startY == 0) dirY = 1;
			else dirY = -1;
			int cnt = 0;
			for(int i = 0; i < L; i++){
				for(int j = 0; j < L; j++){
					if(abs(0.0+token[i][j] - token_[startX+dirX*i][startY+dirY*j]) < 100.5){
						cnt++;
					}
				}
			}
			if(cnt > maxToken) maxToken = cnt;
			cnt=0;
			for(int i = 0; i < L; i++){
				for(int j = 0; j < L; j++){
					if(abs(0.0+token[i][j] - token_[startX+dirX*j][startY+dirY*i]) < 100.5){
						cnt++;
					}
				}
			}
			if(cnt > maxToken) maxToken = cnt;
		}
		printf("%.2lf\n", maxToken*100.0/L/L);
	}
	return 0;
}

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