/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 2ms 532.0 KiB
#2 Wrong Answer 63ms 564.0 KiB

Code

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

int lcd(int n, int m)
{
    int t;
    if (n < m)
    {
        t = n;
    }
    if (n > m)
    {
        t = m;
    }
    if(t == 1){
        return 1;
    }
    for (int i = 2; i < t; i++)
    {
        if (m % i == 0 && n % i == 0)
        {
            // cout << i << endl;
            return i;
        }
    }
    return -1;
}
int main()
{
    int tcase;
    cin >> tcase;
    while (tcase--)
    {
        int n, m;
        cin >> n >> m;
        cout << lcd(n, m) << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1011 LCD
Contest
Brain booster - 1
Language
C++20 (G++ 13.2.0)
Submit At
2023-12-31 14:35:05
Judged At
2024-11-11 03:46:14
Judged By
Score
0
Total Time
63ms
Peak Memory
564.0 KiB