Educational Codeforces Round 86 (Rated for Div. 2) A

链接:https://codeforces.com/contest/1342/problem/A

题意:两种操作方式,问最小花费使得x=y=0;

签到题,分情况讨论:

code:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
int a[N];
int gcd(int a,int b)
{
   return b==0?a:gcd(b,a%b);
}
void solve()
{
   ll x,y,a,b;
   scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
   ll ans=0;
   if(x!=y)
       ans+=min(abs(x-y)*a+min(x,y)*b,(x+y)*a);
   else
       ans+=min((x+y)*a,x*b);
   printf("%lld
",ans);
   
}
int main()
{
   int t;
   scanf("%d",&t);
   while(t--) solve();
   //system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/sweetlittlebaby/p/12788617.html