using namespace std;
void main()
{
int w,x,y,z;
w = 0;
for( x = 0;x <= 100;x++)
for( y = 0;y <= 100;y++)
for( z = 0;z <= 100;z++)
if ((x+2*y+z*5)==100)
{
w++;
}
cout << w <<endl;
}
心得:只要2跟5的组合加起来不超过100就可以成为一个组合(剩下的由1来补): int main(){ int x2,x5; int count=0; for(x5=0;x5<=20;x5++) for(x2=0;x2<=50;x2++) if(5*x5+2*x2<=100)count++; cout<<count<<endl; return 0;}