online_judge_1250

#include 

using namespace std;

const int N = 10;
int a[N][N];
bool isChange(int n, int sumOld, int sumOven);
void init(int n, int &sumOld, int &sumOven);

int main()
{
    int n;
    int sumOld = 0, sumOven = 0;
    while(cin>>n)
    {
        if(n==0)
            break;
        sumOld = 0, sumOven = 0;
        init(n, sumOld, sumOven);
        if(isChange(n, sumOld, sumOven))
            cout<<"Yes"<>a[i][j];
            if(((i+j)&1) == 1)
                sumOld+=a[i][j];
            else
                sumOven+=a[i][j];
        }
    }
}

bool isChange(int n, int sumOld, int sumOven)
{
    int i,j;
    if(sumOld != sumOven)
        return false;
    int tmpSum;
    for(i=0; i=0)
                tmpSum += a[i-1][j];
            if(i+1=0)
                tmpSum += a[i][j-1];
            if(j+1 tmpSum)
                return false;
        }
    }
    return true;
}

 

这个题目有意思。。。关键是这个充分必要条件。。这是数论里面的知识吗?

你可能感兴趣的:(Online,C++)