记录详情

Time Exceeded

foo.c: In function 'main':
foo.c:52:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ^~~~~~~~~~~~~~~
foo.c:56:9: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &n);
         ^~~~~~~~~~~~~~~
foo.c:60:13: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[j]);
             ^~~~~~~~~~~~~~~~~~
foo.c:62:13: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &b[j]);
             ^~~~~~~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Time Exceeded ≥1395ms ≥256.0 KiB
#2 Time Exceeded ≥1392ms ≥256.0 KiB
#3 Time Exceeded ≥1893ms ≥576.0 KiB

代码

#include<stdio.h>

void gy(int a, int b)
{
    int a1 = a, b1 = b;
    if(a < b)
    {
        int temp = a;
        a = b;
        b = temp;
    }
    while(a - b != b)
    {
        int temp = a - b;
        a = b;
        b = temp;
    }
    a1 = a1 / b;
    b1 = b1 / b;
    printf("%d %d", a1, b1);
}

void lim(int *a1, int *b1, int n)
{
    int a = 0 , b = 0;
    int a_judge = 0, b_judge = 0;
    for (int i = n - 1; a_judge == 0 && b_judge == 0; i--)
    {
        if(*(a1 + i) != 0 && a_judge == 0)
        {
            a_judge = i;
            a = *(a1 + i);
        }
        if(*(b1 + i) != 0 && b_judge == 0)
        {
            b_judge = i;
            b = *(b1 + i);
        }
    }
    if(a_judge > b_judge)
        printf("infty");
    else if(a_judge < b_judge)
        printf("0 1");
    else
        gy(a, b);
}

int main()
{
    int t = 0;

    scanf("%d", &t);
    for (int i = 0; i < t; i++)
    {
        int n = 0;
        scanf("%d", &n);
        n++;    //From a[0] to a[n]
        int a[n], b[n];
        for (int j = 0; j < n; j++)
            scanf("%d", &a[j]);
        for (int j = 0; j < n; j++)
            scanf("%d", &b[j]);
        lim(a, b, n);
    }

    return 0;
}

信息

递交者
类型
递交
题目
P1000 hitwh 2019 新生赛 A ∞
语言
C
递交时间
2020-12-22 15:50:44
评测时间
2020-12-22 15:50:44
评测机
分数
0
总耗时
≥4681ms
峰值内存
≥576.0 KiB