#include<stdio.h>
int main()
{
int n,i,s,a,b,temp;
scanf("%d",&n);
for(i = 1;i <= n;i++){
scanf("%d %d",&a,&b);
if(a<b){
temp=a;
a=b;
b=temp;
}
while(a%b!=0){
s=a;
a=b;
b=s%a;
}
printf("%d\n",b);
}
return 0;
}
int main()
{
int n,i,s,a,b,temp;
scanf("%d",&n);
for(i = 1;i <= n;i++){
scanf("%d %d",&a,&b);
if(a<b){
temp=a;
a=b;
b=temp;
}
while(a%b!=0){
s=a;
a=b;
b=s%a;
}
printf("%d\n",b);
}
return 0;
}
#include
ReplyDeleteint main()
{
int N, F1, F2, i, Flag, j, temp;
scanf("%d", &N);
for (i=1; i<=N; i++)
{
scanf("%d %d", &F1, &F2);
if (F1>F2)
{
temp=F1;
F1=F2;
F2=temp;
}
for (j=1; j<=F1; j++)
{
if (((F1%j)==0) && ((F2%j)==0))
{
Flag=j;
}
}
printf("%d\n", Flag);
}
return 0;
}
what is wrong on my code?
why i get "time limit exeded"?
#include
Deleteint main()
{
int N,F1,F2,i,gcm;
scanf("%d",&N);
while(N--)
{
scanf("%d%d",&F1,&F2);
for(i=1;i<=F1&&i<=F2;i++)
{
if(F1%i==0&&F2%i==0)
{
gcm=i;
}
}
printf("%d\n",gcm);
}
return 0;
}
same problem
#include
ReplyDeleteint main() {
int N, F1, F2, i, Bigger;
scanf("%d", &N);
if(N>=1 && N<=3000) {
while(N--) {
scanf("%d%d", &F1, &F2);
if((F1>=1 && F1<=1000) && (F2>=1 && F2<=1000)) {
for(i=1; i<=1000; i++) {
if(F1%i==0 && F2%i==0) {
Bigger = i;
}
}
printf("%d\n", Bigger);
}
}
}
return 0;
}
#include
ReplyDeleteint main()
{
int i,j,a,b,n;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
scanf("%d%d",&a,&b);
int max =0;
if(ab)
{
for(j=1; j<=b; j++)
{
if(a%j == 0 && b%j == 0)
{
if(max<j)
{
max = j;
}
}
}
printf("%d\n",max);
}
}
return 0;
}
runtime error why !!!!!!!!!!!!