Wrong Answer
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;
}
else if(t == 0){
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++17 (G++ 13.2.0)
- Submit At
- 2023-12-31 14:39:45
- Judged At
- 2024-11-11 03:46:11
- Judged By
- Score
- 0
- Total Time
- 61ms
- Peak Memory
- 556.0 KiB