/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 1ms 324.0 KiB
#3 Wrong Answer 2ms 484.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=2000000007;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    map<int,int>one,two,three;
    ll x;
    set<int>st;
    vector<int>v;
    one[1]++;
    two[1]++;
    three[1]++;
    for(int i=1;i<=3;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    cin>>x;
    int cur=1;
    for(int i:v){
       ll d=i;
       for(ll j=2;j*j<=d;j++){
           if(d%j==0){
            st.insert(j);
            while(d%j==0 && d>1){
                d/=j;
                if(cur==1)one[j]++;
                if(cur==2)two[j]++;
                if(cur==3)three[j]++;
            }
           }
       }
       if(d>1){
        st.insert(d);
         if(cur==1)one[d]++;
                if(cur==2)two[d]++;
                if(cur==3)three[d]++;
       }
       cur++;
    }
    ll res=1;
    for(auto it:st){
      ll i=it;
      int mx=max({one[it],two[it],three[it]});
      while(mx>0){
        if(res*i>=x){
            res=-1;
            break;
        }
        res*=i;
        mx--;
      }
      if(res==-1)break;
    }
    cout<<res<<"\n";



    
   }
   return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1025 GCM
Contest
Brain booster #2
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-06 16:39:32
Judged At
2024-11-11 03:41:15
Judged By
Score
2
Total Time
2ms
Peak Memory
484.0 KiB