Time Exceeded
Code
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
int a, b, n, lcd=0;
cin >> a >> b;
n = 2;
while (1)
{
if ((a % n == 0) && (b % n == 0))
{
lcd = n;
break;
}
++n;
}
if (lcd != 0)
{
cout << lcd << endl;
}
else cout<<"-1"<<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 13:44:36
- Judged At
- 2024-11-11 03:46:35
- Judged By
- Score
- 40
- Total Time
- ≥3084ms
- Peak Memory
- ≥572.0 KiB