枚举、先把数值转为整数,便于计算
答案:11
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 int a[50005]; 5 int main(){ 6 int n=23,m=19,sum=823; 7 int flag=0,x,y; 8 for(x=1;;x++){ 9 for(y=x+1;;y++){ 10 if(x*n+y*m==sum){ 11 flag=1; 12 cout<<"啤酒:"<<x<<" 饮料"<<y<<endl; 13 break; 14 } 15 if(x*n+y*m>sum){ 16 break; 17 } 18 } 19 if(flag) { 20 break; 21 } 22 } 23 return 0; 24 }