結果

問題 No.314 ケンケンパ
ユーザー akakimidori
提出日時 2017-01-31 17:55:21
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 1,058 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 13,144 KB
最終ジャッジ日時 2024-12-23 22:50:12
合計ジャッジ時間 1,373 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:6:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~

ソースコード

diff #

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

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

  if(n==1){
    printf("0\n");
    return;
  }

  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