結果

問題 No.314 ケンケンパ
コンテスト
ユーザー Leonardone
提出日時 2015-12-08 08:41:31
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 477 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 92 ms
コンパイル使用メモリ 21,704 KB
最終ジャッジ日時 2026-02-23 19:59:28
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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)
main.c: In function ‘main’:
main.c:18:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%d", &k);
      |     ^~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

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

typedef unsigned long ul;

const ul MD = 1000000007UL;

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


int main(void) {
    
    register ul a, b = 1UL, c, ta, n;
    int k;
    
    scanf("%d", &k);
    n = k;
    
    while (--n) {
        ta = (b + c) % MD;
        c = b;
        b = a;
        a = ta;
    }

    
    printf("%lu\n", (a + b + c) % MD);
    
    return 0;
}

0