| ||||||||||
| 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 | |||||||||
是因为数据太弱吗,照感觉写了一下竟然过了#include <cstdio>
int n, arr[1000][1000];
int leftUpToRightDown(int c)
{
int i = (c+1) % n, j = 1, res = arr[0][c];
while(i != c){
res += arr[j++][i];
if(++i == n) i = 0;
}
return res;
}
int rightUpToLeftDown(int c)
{
int i = (c-1+n) % n, j = 1, res = arr[0][c];
while(i != c){
res += arr[j++][i];
if(--i < 0) i = n-1;
}
return res;
}
bool check()
{
int sum = leftUpToRightDown(0);
for(int i = 1; i < n; ++i){
if(sum != leftUpToRightDown(i)) return false;
}
for(int i = n-1; i > -1; --i){
if(sum != rightUpToLeftDown(i)) return false;
}
return true;
}
int main()
{
while(scanf("%d", &n), n){
for(int i = 0; i < n; ++i)
for(int j = 0; j < n; ++j) scanf("%d", arr[i]+j);
if(check()) puts("homogeneous");
else puts("not homogeneous");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator