/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 2ms 536.0 KiB

Code

/**
    Author : Abdullah Al Mahdi
    CF Handle: abdmahdi56
    Leading University,Sylhet

    Submitted on:
*/
#include <bits/stdc++.h>
#define endl '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define vi vector<ll>
#define all(v) v.begin(), v.end()
#define loop(i,n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

void Bismillah() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void solve() {
    int x,y;
    cin>>x>>y;
    int ans=min(x,y)+1;
    bool ok=true;
    if(x==1 || y==1){
        cout<<-1<<endl;
        return ;
    }
    while(ok){
        if(ans %x!=0 && ans%y!=0 && ans<=100){
            ok =false;
            cout<<ans<<endl;
        }else ans++;
    }
}

int main() {
    Bismillah();
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1235 A. Valid Integer
Contest
Happy New Year 2026
Language
C++17 (G++ 13.2.0)
Submit At
2026-01-06 14:47:35
Judged At
2026-01-06 14:47:35
Judged By
Score
100
Total Time
2ms
Peak Memory
536.0 KiB