提交记录 #34
提交时间:2024-10-29 20:07:53
语言:c
状态:Unaccepted
编译情况:编译成功
固定测试点#1:
附加测试点暂不可用
M13【期中测验1】3. 礼品店促销
#include<stdio.h>
void findCombinations(int price[],int tm,int tn){
for(int i=1;i<=tn;i++){
for(int j=i;j<=tn-i;j++){
for(int k=j;k<=tn-i-j;k++){
for(int l=k;l<=tn-i-j-k;l++){
int m=tn-i-j-k-l;
if (m>=1&&i*price[0]+j*price[1]+k*price[2]+l*price[3]+m*price[4]==tm){
printf("%d,%d,%d,%d,%d\n",i,j,k,l,m);
}
}
}
}
}
}
int main(){
int prices[5];
int tm,tc;
for (int i=0;i<5;i++){
scanf("%d",&prices[i]);}
scanf("%d %d",&tm,&tc);
findCombinations(prices, tm,tc);
return 0;
}