1118A - Water Buying - CodeForces Solution


math *800

Please click on ads to support us..

Python Code:

t = int(input())
for _ in range(t):
    n, a, b = (int(i) for i in input().split())
    res = min(n*a, (n // 2) * b + (n % 2) * a)
    print(res)

C++ Code:

#include <bits/stdc++.h>

using namespace std;

int main()
{   
    int t;
    cin>>t;
    while(t--){
       long long a,b,c;
       cin>>a>>b>>c;
       long long sum1,sum2;
       sum1=a*b;
       sum2=(a/2)*c;
       if(a%2!=0)
       sum2+=b;
       
       cout<<min(sum1,sum2)<<endl;
        
        
        
        
        
    }
        
        

}


Comments

Submit
0 Comments
More Questions

975C - Valhalla Siege
518B - Tanya and Postcard
514B - Han Solo and Lazer Gun
898B - Proper Nutrition
9C - Hexadecimal's Numbers
1265B - Beautiful Numbers
745A - Hongcow Learns the Cyclic Shift
873A - Chores
1754B - Kevin and Permutation
1547D - Co-growing Sequence
1754D - Factorial Divisibility
1117B - Emotes
412B - Network Configuration
845B - Luba And The Ticket
1732A - Bestie
389A - Fox and Number Game
1732B - Ugu
1100B - Build a Contest
1181B - Split a Number
1313B - Different Rules
1736D - Equal Binary Subsequences
1754A - Technical Support
26B - Regular Bracket Sequence
699A - Launch of Collider
474D - Flowers
1016A - Death Note
1335C - Two Teams Composing
1167C - News Distribution
813C - The Tag Game
1130C - Connect