记录详情

Accepted

/in/foo.c: In function 'fun':
/in/foo.c:12:9: warning: 'max' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return max;
         ^~~
/in/foo.c: In function 'main':
/in/foo.c:42:3: warning: 'max' may be used uninitialized in this function [-Wmaybe-uninitialized]
   printf("%d %d\n",lista[i]/fun(lista[i],listb[j]),listb[j]/fun(lista[i],listb[j]));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/in/foo.c:42:3: warning: 'max' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 状态 耗时 内存占用
#1 Accepted 2ms 144.0 KiB
#2 Accepted 12ms 216.0 KiB
#3 Accepted 103ms 216.0 KiB

代码

#include<stdio.h>
int fun(int a,int b)
{
	int i,max;
	for(i=1;i<=a&&i<=b;i++)
	{
		if(a%i==0&&b%i==0)
		{
			max=i;
		}
	}
	return max;
}
int main()
{
	int T;
	int n;
	int i,j;
	int lista[10000];
	int listb[10000];
	scanf("%d",&T);
	while(T>0)
	{
		scanf("%d",&n);
		for(i=0;i<=n;i++)
		scanf("%d",&lista[i]);
		for(i=0;i<=n;i++)
		scanf("%d",&listb[i]);
		for(i=n;i>=0;i--)
		{
			if(lista[i]!=0)
			break;
		}
		for(j=n;j>=0;j--)
		{
			if(listb[j]!=0)
			break;
		}
		if(i>j)
		printf("infty\n");
		else if(i==j)
		printf("%d %d\n",lista[i]/fun(lista[i],listb[j]),listb[j]/fun(lista[i],listb[j]));
		else
		printf("0 1\n");
		T--;
	}
	return 0;
}

信息

递交者
类型
递交
题目
P1000 hitwh 2019 新生赛 A ∞
语言
C
递交时间
2020-12-24 14:28:17
评测时间
2020-12-24 14:28:17
评测机
分数
100
总耗时
118ms
峰值内存
216.0 KiB