結果

問題 No.314 ケンケンパ
ユーザー Leonardone
提出日時 2015-12-08 08:26:53
言語 C90
(gcc 12.3.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 870 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 26,112 KB
最終ジャッジ日時 2025-01-27 01:22:39
合計ジャッジ時間 835 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:1:1: error: C++ style comments are not allowed in ISO C90
    1 | // yukicoder My Practice
      | ^
main.c:1:1: note: (this will be reported only once per input file)

ソースコード

diff #

// yukicoder My Practice
// author: Leonardone @ NEETSDKASU
#include <stdio.h>

typedef unsigned long ul;

const ul MD = 1000000007UL;

// 解説読後
// http://yukicoder.me/problems/882/editorial

#define arrlen(x) (sizeof(x) / sizeof((x)[0]))

char str[100];
ul a[1000006];
ul *an = a + 3, *an2 = a + 1, *end = a + 1000005; 

int main() {
    
    *an2 = 1UL;
    while (an != end) {
        *(an++) = ((*(an - 2)) + (*(an - 3))) % MD;
    }
    
    int n = 0;
    int k = fread(str, sizeof(char), arrlen(str), stdin);
    str[k - 1]= 0;
    char *p = str;
    while (*p) {
        n = (n * 10) + (int)(*p++ - '0');
    }
    
    ul r = a[n + 4], t;
    
    *(p = str + 98) = '\n';
    while (r) {
        t = r / 10UL;
        *(--p) = '0' + (char)(r - 10UL * t);
        r = t;
    }
    
    fwrite(p, sizeof(char), str + 99 - p, stdout);
    
    return 0;
}

0