結果

問題 No.314 ケンケンパ
コンテスト
ユーザー akakimidori
提出日時 2017-01-31 17:56:04
言語 C90
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 517 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 180 ms
コンパイル使用メモリ 38,888 KB
最終ジャッジ日時 2026-02-24 00:14:15
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
#include<stdlib.h>

void run(void){
  int n;
  scanf("%d",&n);

  const int mod=1000000007;

  int *ken=(int *)calloc(n+1,sizeof(int));
  int *kenken=(int *)calloc(n+1,sizeof(int));
  int *pa=(int *)calloc(n+1,sizeof(int));

  ken[1]=1;
  int i;
  for(i=2;i<=n;i++){
    ken[i]=pa[i-1];
    kenken[i]=ken[i-1];
    pa[i]=(ken[i-1]+kenken[i-1])%mod;
  }
  printf("%d\n",((ken[n]+kenken[n])%mod+pa[n])%mod);
  free(ken);
  free(kenken);
  free(pa);
  return;
}

int main(void){
  run();
  return 0;
}
0