1 solutions
-
0_MJiH_ LV 4 MOD @ 2024-09-05 21:20:26
#include <bits/stdc++.h> using namespace std; #define SC scanf #define PF printf #define ull unsigned long long #define ld long double #define F first #define S second #define pb push_back #define sort_a(a) sort(a.begin(),a.end()); #define sort_d(a) sort(a.rbegin(),a.rend()); #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) #define rev(s) reverse(s.begin(),s.end()) #define P(ok) cout << (ok ? "YES\n": "NO\n") #define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL); #define ll long long typedef pair< ll , ll> PII; void solve() { ll n , d , a, b ; cin >> n >> d >> a >> b; ll Ans = min(n , d) * a ; n -= min(n , d) ; Ans = Ans + (n * b) ; cout << Ans << "\n" ; } int main() { __Heart__ // READ("input8.txt") ; //WRITE("output8.txt") ; int t ; cin >> t ; while(t--) solve() ; }
- 1
Information
- ID
- 1090
- Difficulty
- 4
- Category
- Beginners | Math Click to Show
- Tags
- # Submissions
- 216
- Accepted
- 89
- Accepted Ratio
- 41%
- Uploaded By