Time Exceeded
Code
#include<stdio.h>
int main()
{
int T;
scanf("%d", &T);
for(int j = 1; j<=T; j++)
{
long int n, m, div = 0;
scanf("%ld %ld", &n, &m);
if(n>m)
{
for(int i = n; i>1; i--)
{
if(n%i == 0 && m%i == 0)
{
div = i;
}
}
if(div == 0)
{
printf("-1\n");
}
else
{
printf("%d\n", div);
}
}
else if(m > n)
{
for(int i = m; i>1; i--)
{
if(n%i == 0 && m%i == 0)
{
div = i;
}
}
if(div == 0)
{
printf("-1\n");
}
else
{
printf("%d\n", div);
}
}
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1011 LCD
- Contest
- Brain booster - 1
- Language
- C99 (GCC 13.2.0)
- Submit At
- 2023-12-31 14:08:14
- Judged At
- 2024-11-11 03:46:23
- Judged By
- Score
- 10
- Total Time
- ≥3088ms
- Peak Memory
- ≥424.0 KiB