记录详情

Accepted

/in/foo.c: In function 'simpli':
/in/foo.c:15:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 状态 耗时 内存占用
#1 Accepted 1ms 212.0 KiB
#2 Accepted 10ms 624.0 KiB
#3 Accepted 97ms 4.215 MiB

代码

#include <stdio.h>
#include <stdlib.h>
int simpli(int m,int n)
{
    int p = m,q = n;
    int rem;
    while(n>0)
    {
        rem = m%n;
        m = n;
        n = rem;
    }

    printf("%d %d",p/m,q/m);
}
int main()

{
    int m,i,j;
    scanf("%d",&m);
    int *b1[100],*b2[100];
    int b[100];
    for(i = 0; i<m; i++)
        {
            scanf("%d",&b[i]);
            b1[i] = (int *)calloc(b[i]+1,sizeof(int));
            b2[i] = (int *)calloc(b[i]+1,sizeof(int));

        for(j = 0; j<=b[i]; j++)
            scanf("%d",b1[i]+j);
        for(j = 0; j<=b[i]; j++)
            scanf("%d",b2[i]+j);
        //for(j = 0; j<=b[i]; j++)
          //  printf("%d",*(b1[i]+j));
        //for(j = 0; j<=b[i]; j++)
          //  printf("%d",*(b2[i]+j));
    }
    for(i = 0; i<m; i++)
    {
        j = b[i];
        while(0==*(b1[i]+j)&&0==*(b2[i]+j))
            j--;
        if(0==*(b1[i]+j))
            printf("0 1");
        else if(0==*(b2[i]+j))
            printf("infty");
        else
        {
            simpli(*(b1[i]+j),*(b2[i]+j));
        }
        printf("\n");
    }
    for(i = 0;i<m;i++)
    {
        free(b1[i]);
        free(b2[i]);
    }
    return 0;
}

信息

递交者
类型
递交
题目
P1000 hitwh 2019 新生赛 A ∞
语言
C
递交时间
2020-12-25 19:53:18
评测时间
2020-12-25 23:31:11
评测机
分数
100
总耗时
110ms
峰值内存
4.215 MiB