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 chenjin1st at 2012-02-01 10:56:36 on Problem 2260
使用了两个嵌套循环也能过。数据好弱。题意就是判断一个方阵个个行和列的和是不是都是偶数,如果不是能不能改变一个满足要求

代码如下。写的十分的丑陋。

#include<stdio.h>
#include<stdlib.h>
int main(){
	int n,**arr,i,j,row,col,ei,ej,eni,enj;
	while(scanf("%d",&n)==1&&n){
		arr=(int **)malloc(n*sizeof(int *));
		for(i=0;i<n;i++){
			arr[i]=(int *)malloc(n*sizeof(int));
			for(j=0;j<n;j++)
				scanf("%d",&arr[i][j]);
		}
		eni=enj=ei=ej=0;
		for(i=0;i<n;i++){
			for(row=j=0;j<n;j++)
				row+=arr[i][j];
			if(row%2){
				ei=i;
				eni++;
			}
		}
		for(j=0;j<n;j++){
			for(col=i=0;i<n;i++)
				col+=arr[i][j];
			if(col%2){
				ej=j;
				enj++;
			}
		}
		if(!(enj+eni)){
			printf("OK\n");
		}else{
			if(enj==1&&eni==1)
				printf("Change bit (%d,%d)\n",ei+1,ej+1);
			else
				printf("Corrupt\n");
		}
		for(i=0;i<n;i++)
			free(arr[i]);
		free(arr);
	}
	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