結果

問題 No.314 ケンケンパ
ユーザー akakimidoriakakimidori
提出日時 2017-01-31 17:55:21
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 24,524 KB
実行使用メモリ 13,264 KB
最終ジャッジ日時 2023-08-25 14:23:02
合計ジャッジ時間 1,352 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
12,952 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 6 ms
7,212 KB
testcase_19 AC 9 ms
13,264 KB
権限があれば一括ダウンロードができます

ソースコード

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