(C++)201709-1 打酱油
作者:互联网
#include<cstdio>
#include<algorithm>
using namespace std;
//贪心问题,优先级:剩的钱购买5瓶就买5瓶,不够看够不够买三瓶,再不够看够不够买一瓶
int main(){
int start,left,num=0;//初始的钱,当前剩下的钱,买到的瓶数
scanf("%d",&start);
left=start;
while(1){
if(left>=50){
left-=50;
num+=7;
}else if(left>=30){
left-=30;
num+=4;
}else if(left>=10){
left-=10;
num+=1;
}else{
break;
}
}
printf("%d\n",num);
return 0;
}
标签:不够看,201709,酱油,C++,else,start,int,num,left 来源: https://blog.csdn.net/weixin_44997802/article/details/115588993