/ Randle /

记录详情

Time Exceeded

foo.c: In function 'main':
foo.c:11:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ^~~~~~~~~~~~~~~
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 0ms 256.0 KiB
#2 Wrong Answer Read 1365010941, expect 365010934. 0ms 256.0 KiB
#3 Wrong Answer Read 1107579946, expect 107579939. 0ms 256.0 KiB
#4 Accepted 474ms 284.0 KiB
#5 Time Exceeded ≥1424ms ≥304.0 KiB
#6 Time Exceeded ≥1448ms ≥256.0 KiB
#7 Time Exceeded ≥1454ms ≥228.0 KiB
#8 Time Exceeded ≥1448ms ≥196.0 KiB
#9 Time Exceeded ≥1451ms ≥240.0 KiB
#10 Time Exceeded ≥1959ms ≥284.0 KiB

代码

#include <stdio.h>
// 目前该题解出现6个Time Exceeded
int dp[3] = {0};  // 因为到达当前台阶的走法只与前面2个台阶的走法有关

int main(int argc, char const *argv[])
{
    dp[0] = 1;
    dp[1] = 2;

    int n;
    scanf("%d", &n);
    while (n -- > 2){
        dp[2] = dp[0] + dp[1];
        dp[0] = dp[1] % (int) (1e9+7);
        dp[1] = dp[2] % (int) (1e9+7);
    }
    printf("%d", dp[2]);
    return 0;
}

信息

递交者
类型
递交
题目
上楼梯(数据原创)
题目数据
下载
语言
C
递交时间
2021-10-01 17:37:19
评测时间
2021-10-01 17:37:19
评测机
分数
20
总耗时
≥9663ms
峰值内存
≥304.0 KiB