/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 320.0 KiB
#2 Wrong Answer 111ms 612.0 KiB
#3 Wrong Answer 110ms 604.0 KiB

Code

/*
ALLAH IS THE GREATEST
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl "\n"
const ll Mod = 2e18+7;
const ll N = 1e5+7;
#define Subhanallah_Alhamdulillah_Allahu_Akbar ios_base::sync_with_stdio(false);cin.tie(NULL);
bool bs[10000007];
const ll sz = 1e6+5;
typedef pair<ll,ll>pi;
vector<ll>prime;
ll vis[N];
ll arr[N];
vector<ll>graph[N];
void sieve()
{
    bs[0]=bs[1]=1;
    for(ll i=3;i*i<=sz;i+=2)
    {
        if(!bs[i])
        {
            for(ll j=i*i;j<=sz;j+=i)
            {
                bs[j]=1;
            }
        }
    }
    prime.push_back(2);
    for(ll i=3;i<=sz;i+=2)
    {
        if(!bs[i])
        {
            prime.push_back(i);
        }
    }
    sort(prime.rbegin(),prime.rend());
}
ll mod(ll a, ll m){
    return (a % m + m) % m;
}
ll biexpo(ll base,ll power)
{
    ll ans =1;
    while(power)
    {
        if(power%2==1)
        {
            ans=(ans*base);
            power--;
        }
        else
        {
            base=(base*base);
            power/=2;
        }
    }
    return ans;
}
ll dfs(ll n)
{
    vector<ll>v;
    vis[n]=1;
    stack<ll>st;
    st.push(n);
    while(!st.empty())
    {
    ll cur = st.top();
    v.push_back(cur);
    st.pop();
    for(auto &i:graph[cur])
    {
        if(!vis[i])
        {
            st.push(i);
            vis[i]=1;
        }
    }
    }
    ll mi = 1e18;
    for(auto &k:v)
    {
        mi = min(mi,arr[k-1]);
    }
    return mi;
}
ll digsum(ll a)
{
    ll sum=0;
    while(a)
    {
        sum+=(a%10);
        a/=10;
    }
    return sum;
}

int main()
{
    //Think positively and move on
    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        if(a==b && b==c)
        {
            cout<<0<<nl;
            continue;
        }
        vector<ll>v,u;
        v.push_back(a);
        v.push_back(b);
        v.push_back(c);
        map<ll,ll>mp;
        for(ll i=0;i<v.size();i++)
        {
            mp[v[i]]++;
        }
        ll mx = INT_MIN;
        for(ll i=0;i<3;i++)
        {
            mx = max(mp[v[i]],mx);
        }
        if(mx==2)
        {
            cout<<1<<nl;
            continue;
        }
        for(ll i=0;i<v.size();i++)
        {
            for(ll j=1;j*j<=v[i];j++)
            {
                if(v[i]%j==0)
                {
                    u.push_back(j);
                    if(j!=(v[i]/j))
                    {
                        u.push_back(v[i]/j);
                    }
                }
            }
        }
        ll sk;
        map<ll,ll>dp;
        for(ll i=0;i<u.size();i++)
        {
            dp[u[i]]++;
        }
        for(auto &k:dp)
        {
           if(k.second==3)
           {
              sk=k.first;
           }
        }
        sort(v.begin(),v.end());
        ll uk = v[0]/sk+v[1]/sk;
        ll vk = v[1]/sk+v[2]/sk;
        ll tk = v[0]/sk+v[2]/sk;
        ll ans = min(uk,vk);
        cout<<min(ans,tk)<<nl;

    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1061 Bring equality
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 16:26:39
Judged At
2024-11-11 03:24:10
Judged By
Score
10
Total Time
111ms
Peak Memory
612.0 KiB