⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2941.txt

📁 北大ACM题目例程 详细的解答过程 程序实现 算法分析
💻 TXT
字号:
Problem Id:2941  User Id:fzk 
Memory:4008K  Time:562MS
Language:C++  Result:Accepted

Source 

#include <algorithm>
#include <cstdio>
#include <string.h>
#include <map>
#include <stack>
#include <memory.h>
#include <math.h>
#include <queue>
using namespace std;

int a[1010][1010];


int main( ){
	int n, i, j, t;
	bool key;
	while( 1 ) {
		scanf( "%d", &n );
		if( n == 0 )
			break;
		for( i=0; i<n; i++ )
		for( j=0; j<n; j++ )
			scanf( "%d", &a[i][j] );
		if( n == 1 )
			key = true;
		else if( n == 2 )
			key = ( a[0][0]+a[1][1] == a[1][0]+a[0][1] );
		else {
			for( i=0; i<n-1; i++ ) {
				t = a[i][0]-a[i+1][0];
				for( j=1; j<n; j++ )
					if( a[i][j]-a[i+1][j] != t )
						break;
				if( j<n )
					break;
			}
			
			key = ( i>= n-1 );
		}
		
		if( key ) printf( "homogeneous\n" );
		else printf( "not homogeneous\n" );
	}
	return 0;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -