Accepted
foo.c: In function 'main': foo.c:7:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&m); ^~~~~~~~~~~~~~ foo.c:13:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^~~~~~~~~~~~~~ foo.c:17:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&b[j]); ^~~~~~~~~~~~~~~~~ foo.c:21:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&c[j]); ^~~~~~~~~~~~~~~~~
代码
#include<stdio.h>
#define N 10010
int main()
{
int m=0,n=0;
int a[N][2]={0};
scanf("%d",&m);
for(int i=0;i<m;i++)
{
int b[N]={0};
int c[N]={0};
scanf("%d",&n);
for(int j=0;j<=n;j++)
{
scanf("%d",&b[j]);
}
for(int j=0;j<=n;j++)
{
scanf("%d",&c[j]);
}
for(int j=n;j>=0;j--)
{
if(b[j]==0&&c[j]==0) continue;
else if(b[j]==0&&c[j]!=0)
{
a[i][0]=0;
a[i][1]=1;
break;
}
else if(b[j]!=0&&c[j]==0)
{
a[i][0]=-1;
a[i][1]=-1;
break;
}
else
{
int t=b[j]<c[j]?b[j]:c[j];
for(int k=2;k<=t;k++)
{
if(b[j]%k==0&&c[j]%k==0)
{
b[j]/=k;c[j]/=k;k--;
}
}
a[i][0]=b[j];
a[i][1]=c[j];
break;
}
}
}
for(int i=0;i<m;i++)
{
if(a[i][0]==-1)
printf("infty\n");
else
printf("%d %d\n",a[i][0],a[i][1]);
}
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- P1000 hitwh 2019 新生赛 A ∞
- 语言
- C
- 递交时间
- 2020-12-21 20:49:20
- 评测时间
- 2020-12-21 20:49:20
- 评测机
- 分数
- 100
- 总耗时
- 116ms
- 峰值内存
- 464.0 KiB