SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /// Typedef
  6. typedef long long ll;
  7.  
  8. #define sc1(a) scanf("%lld",&a)
  9. #define sc2(a,b) scanf("%lld %lld",&a,&b)
  10.  
  11. #define pf1(a) printf("%lld\n", a)
  12. #define pf2(a,b) printf("%lld %lld\n",a,b)
  13.  
  14. #define mx 10000007
  15. #define mod 1000000007
  16. #define PI acos(-1.0)
  17.  
  18. #define size1 44
  19.  
  20. int drx[8] = {-2,-2,-1,-1,1,1,2,2};
  21. int dcy[8] = {-1,1,-2,2,-2,2,-1,1};
  22.  
  23. int dirx[4] = { -1, 0, 1, 0 };
  24. int diry[4] = { 0, -1, 0, 1 };
  25.  
  26.  
  27. ll gcd(ll a,ll b){ if(b == 0) return a; return gcd(b, a % b); }
  28. ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  29.  
  30. int main()
  31. {
  32.     ll tc, num, t = 1, pownum;
  33.  
  34.     // freopen("/opt/Coding/clion code/input.txt", "r", stdin);
  35.     // freopen("/opt/Coding/clion code/output.txt", "w", stdout);
  36.  
  37.     sc1(tc);
  38.  
  39.     while (tc--){
  40.  
  41.         ll a, b;
  42.  
  43.         cin >> num >> a >> b;
  44.  
  45.         if(num & 1){
  46.  
  47.             ll first = (num -1) / 1;
  48.             ll last = (num - 1) / 2;
  49.  
  50.             ll ans = min((first * a), (last * b));
  51.  
  52.             ans += a;
  53.             pf1(ans);
  54.         }
  55.         else{
  56.  
  57.             ll first = num / 1;
  58.             ll last = num / 2;
  59.  
  60.             ll ans = min((first * a), (last * b));
  61.             pf1(ans);
  62.         }
  63.  
  64.     }
  65.  
  66.     return 0;
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top