问题一百四十三:寒冰王座
ps:现在死亡骑士希望你能帮他计算一下,最少他要给地精商人多少小费.
[plain] #include <stdio.h>
int main()
{
int i;
int j;
int k;
int n;
int m;
int l;
int num;
int max;
int cost;
int money;
scanf("%d", &num);
while(num--)
{
scanf("%d", &money);
n=money/350;
m=money/200;
l=money/150;
max=0;
for(i=0; i<=n; i++)
{
for(j=0; j<=m; j++)
{
for(k=0; k<=l; k++)
{
cost=i*350+ j*200+ k*150;
if(cost>max && cost<=money)
{
max=cost;
}
}
}
}
printf("%d", money-max);
if(num>0)
{
printf("\n");
}
}
}
#include <stdio.h>
int main()
{
int i;
int j;
int k;
int n;
int m;
int l;
int num;
int max;
int cost;
int money;
scanf("%d", &num);
while(num--)
{
scanf("%d", &money);
n=money/350;
m=money/200;
l=money/150;
max=0;
for(i=0; i<=n; i++)
{
for(j=0; j<=m; j++)
{
for(k=0; k<=l; k++)
{
cost=i*350+ j*200+ k*150;
if(cost>max && cost<=money)
{
max=cost;
}
}
}
}
printf("%d", money-max);
if(num>0)
{
printf("\n");
}
}
}
结果图:
补充:软件开发 , C语言 ,