Untitled

 avatar
unknown
plain_text
2 months ago
451 B
32
Indexable

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int MOD = 1e9 + 7;

// Main function
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);


    int t;
    cin >> t;
    while (t--) {

        int n,a,b; cin>>n>>a>>b;
        int batches = n/3;
        int ans = batches*(min(b,3*a));
        int rem = n%3;
        ans += min(rem*a,b);
        cout  <<ans<<endl;

    }
    return 0;
}
Editor is loading...
Leave a Comment