Time Exceeded
Code
#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int lcd(int x,int y)
{
int mn=min(x,y);
for (int i=2;i<=mn;i++)
{
if (x%i==0 && y%i==0)
{
return i;
}
}
return -1;
}
int main()
{
faster
//int t=1;
int t; cin >> t;
while (t--)
{
int x,y; cin >> x >> y;
cout << lcd(x,y) << endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1011 LCD
- Contest
- Brain booster - 1
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2023-12-31 16:54:46
- Judged At
- 2024-11-11 03:44:59
- Judged By
- Score
- 50
- Total Time
- ≥3027ms
- Peak Memory
- ≥592.0 KiB