Souvenir
Accepts: 1078
Submissions: 2366
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
BestCoder周年纪念赛,趁着还没结束,来一发水题题解(其实是卡题了(/ □ \)囧)
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int n,m,p,q,T,flag;
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d",&n,&m,&p,&q);
if(n<=m)
flag = min(p*n,q);
else
{
if(p<=q/m)
flag = n*p;
else {
int x = n/m*q;
int y = (n-n/m*m)*p;
int z = (n/m+1)*q;
flag = min(x+y,z);
}
}
printf("%d\n",flag);
}
return 0;
}