/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 540.0 KiB
#2 Accepted 3ms 508.0 KiB
#3 Accepted 18ms 640.0 KiB
#4 Accepted 164ms 1.27 MiB
#5 Accepted 165ms 2.266 MiB
#6 Accepted 170ms 2.254 MiB

Code

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define mp make_pair
#define pq priority_queue<int>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define PI acos(-1)
const int M = 1e9 + 7;
ll binExp(ll a, ll b)
{
    int res = 1;
    while (b)
    {
        if (b & 1)
            res = res * a;
        a *= a;
        b /= 2;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
    return (a / gcd(a, b)) * b;
}
ll sum(ll n)
{
    return n * (n + 1) / 2;
}
void solve()
{
    // for (int i = 1; i <= 20; i++)
    // {
    //     for (int j = 1; j <= 20; j++)
    //     {
    //         if (gcd(i, j) != lcm(i, j))
    //         {
    //             cout << i << ' ' << j << endl;
    //         }
    //     }
    // }
    ll a, b;
    cin >> a >> b;
    if (a > b)
        swap(a, b);
    cout << (b - 1) * a << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1075 GCD not equal LCM
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 15:42:54
Judged At
2024-11-11 03:03:04
Judged By
Score
100
Total Time
170ms
Peak Memory
2.266 MiB