记录详情

Runtime Error

/in/foo.c: In function 'sumup':
/in/foo.c:51:12: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return sum;
            ^~~
/in/foo.c: In function 'main':
/in/foo.c:64:5: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
     printf("%d",sum % 1000000007);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Wrong Answer 1ms 212.0 KiB
#2 Wrong Answer 1ms 220.0 KiB
#3 Wrong Answer 0ms 224.0 KiB
#4 Wrong Answer 1ms 220.0 KiB
#5 Runtime Error 8ms 228.0 KiB
#6 Runtime Error 3ms 208.0 KiB
#7 Runtime Error 6ms 204.0 KiB
#8 Runtime Error 5ms 212.0 KiB
#9 Runtime Error 2ms 128.0 KiB
#10 Runtime Error 4ms 204.0 KiB

代码

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int seek(int n,int num[])
{
    int i,k,find;
    int j=1;
    for(k=3; k<=n; k++)//待判定数
    {
        find = 1;
        for(i=2; i<=sqrt(k); i++)
        {
            if(k%i == 0)
                find=0;
        }
        if(find == 1)
        {
            num[j] = k;
            j++;
        }
    }
    return j-1;
}

int  yesorno(int n,int x)
{
    int i=x;
    while(x<=n)
    {
        x = x * i;
    }
    return x/i;
}

void mutiple(int n,int num[],int k)
{
    int i;
    for(i=0; i<=k ; i++)
    {
        num[i] = yesorno(n,num[i]);
    }
}
int sumup(int k,int num[])
{
    int i ;
    int sum;
    for(i=0;i<=k;i++)
    {
        sum = sum * num[i];
    }
    return sum;
}

int main()
{
    int n,j;
    int sum;
    int num[1000];
    num[0] = 2;
    scanf("%d",&n);
    j = seek(n,num);
    mutiple(n,num,j);
    sum = sumup(j,num);
    printf("%d",sum % 1000000007);
    return 0;
}

信息

递交者
类型
递交
题目
篝题
语言
C
递交时间
2020-12-23 23:38:46
评测时间
2020-12-23 23:38:46
评测机
分数
0
总耗时
35ms
峰值内存
228.0 KiB