Souveniraccepts:901submissions:2743Time limit:2000/1000 MS (java/others)Memory limit:262144/262144 K (java/others)Problem description
Today is Bestcoder's one-year anniversary. Game Manager Soda wants to prepare a souvenir for each contestant. The price of the souvenir in the shop is $p$ yuan, but also can spend $q$ yuan to buy souvenir sets, a suit has $m$ souvenir. There are $n$ contestants in total today, and soda want to know how much it will cost to have a souvenir for everyone.
Enter a description
Enter more than one set of data. The first line has an integer $t$ $ (1 \le T \le 10^5) $, which represents the number of test data groups. Then for each set of data: A row contains 4 integers $n, M, p, q$ $ (1 \le N, M, p, Q \le 10^4) $.
Output description
Minimum cost for each set of data output.
Input sample
21 2 2 11 2 3 4
Output sample
13
Hint
For the first set of data, soda can purchase a package for $1. For the second set of data, soda can buy a souvenir directly for $3.
Water.
Just say three words.
Don't use cin!.
Don't use cin!.
Don't use cin!.
/************************************************************************* > File name:code/bc/#ann/1001.cpp > Author:111qqz > Email: [email protected] > Created time:2015 July 25 Saturday 18:54 24 seconds ******************** ****************************************************/#include<iostream>#include<iomanip>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<string>#include<map>#include<Set>#include<queue>#include<vector>#include<stack>#defineY0 ABC111QQZ#defineY1 HUST111QQZ#defineYn hez111qqz#defineJ1 CUTE111QQZ#defineTM CRAZY111QQZ#defineLR DYING111QQZusing namespacestd;#defineREP (i, n) for (int i=0;i<int (n); ++i)typedefLong Longll;typedef unsignedLong LongULL;intn,m,p,q;intMain () {intT; CIN>>T; intAns =0; while(t--) { //scanf ("%d%d%d%d", &n,&m,&p,&q);scanf"%d %d%d%d",&n,&m,&p,&q); Ans= Np; Ans= Min (ans,n/m*q+n%m*p); Ans= Min (ans, (n1)/m+1)*q); printf ("%d\n", ans); } return 0;}
BC Anniversary 1001 Souvenir (Hdu 5310)