AtCoder Beginner Contest 006

Submission #1771652

Source codeソースコード

#include<stdio.h>
int main(void) {
long n;
scanf("%ld",&n);
double a[n];
  for(int i = 1; i < n+1; i++) {
    if(i == 1)
      a[1] = 0;
    else if(i == 2)
      a[2] = 0;
    else if(i == 3)
      a[3] = 1;
    else
    a[i] = a[i-3]%10007 + a[i-2]%10007 + a[i-1]%10007;
  }
double b = fmod(a[n],10007);
printf("%f\n",b);
return (0);
}

Submission

Task問題 B - トリボナッチ数列
User nameユーザ名 tomorrow550
Created time投稿日時
Language言語 C (GCC 5.4.1)
Status状態 CE
Score得点 -
Source lengthソースコード長 357 Byte
File nameファイル名
Exec time実行時間 -
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.c: In function ‘main’:
./Main.c:14:18: error: invalid operands to binary % (have ‘double’ and ‘int’)
a[i] = a[i-3]%10007 + a[i-2]%10007 + a[i-1]%10007;
^
./Main.c:14:33: error: invalid operands to binary % (have ‘double’ and ‘int’)
a[i] = a[i-3]%10007 + a[i-2]%10007 + a[i-1]%10007;
^
./Main.c:14:48: error: invalid operands to binary % (have ‘double’ and ‘int’)
a[i] = a[i-3]%10007 + a[i-2]%10007 + a[i-1]%10007;
^
./Main.c:16:12: warning: implicit declaration of function ‘fmod’ [-Wimplicit-function-declaration]
double b = fmod(a[n],10007);
^
./Main.c:16:12: warning: incompatible implicit declaration of built-in function ‘fmod’
./Main.c:16:12: note: include ‘<math.h>’ or provide a declaration of ‘fmod’
./Main.c:4:1: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%ld",&n);
^

Test case