百马百瓦问题输出值不正确

说明内的代码和下面的代码只是交换了一下给z的赋值和if的条件,结果在输入为3 2时,前者为7(正确值)后者为14,请教各位这个问题是出在哪里了?
问题如下:
共有100匹马驮100块瓦,大马驮m块,小马驮n块,两个马驹驮一块。大马、小马、马驹的匹数会有多种方案,请问共有多少种方案?
输入
输入数据有多组,在一行上输入两个正整数m和n(0<m,n<10)。
输出
在一行上输出合理方案的个数,若不存在则输出"no solution"。
难度
入门
输入示例
3 2
输出示例
7


/*
#include<iostream>
using namespace std;
int main()
{
    int n,m,x,y,z,i;
    while(cin>>n>>m)
    {
        i=0;
        for(x=0;x<=100/n;x++)
        {
            for(y=0;y<=100/m;y++)
            {
                z=(100-n*x-m*y)*2;
                if(z+y+x==100)
                    i++;
            }
        }
        if(i!=0)
    cout<<i<<endl;
    else
        cout<<"no solution"<<endl;
}
}
*/

#include<iostream>
using namespace std;
int main()
{
    int n,m,x,y,z,i;
    while(cin>>n>>m)
    {
        i=0;
        for(x=0;x<=100/n;x++)
        {
            for(y=0;y<=100/m;y++)
            {
                z=100-x-y;
                if((x*n)+(y*m)+(z/2)==100&&z>=0&&y>=0&&x>=0)
                    i++;
            }
        }
        if(i!=0)
    cout<<i<<endl;
    else
        cout<<"no solution"<<endl;
}
}

把问题具体是什么,贴一下可不可以

#include<iostream>

using namespace std;

int main()

{

int n,m,x,y,z,i;

while(cin>>n>>m)

{

i=0;

for(x=0;x<=100/n;x++)

{

for(y=0;y<=100/m;y++)

{

z=100-x-y;

if((x*n)+(y*m)+(z/2)==100&&z>=0&&y>=0&&x>=0)

printf("%d %d %d\n",x,y,z);

}

}

if(i!=0)

cout<<i<<endl;

else

cout<<"no solution"<<endl;

}

}




img