Document directory
IDE environment: Code: Blocks
Series time limit: 1000 ms memory limit: 10000 k total time limit: 3000 Ms
Description:
It is known that the K-order sequence is defined as f0 = 0, F1 = 0 ,..., Fk-2 = 0, fk-1 = 1; fn = fn-1 + fn-2 +... + FN-k, n = K, k + 1 ,..., Write a function algorithm to calculate the M-th value of the k-th order sequence of symmetric pona. Both K and M appear in the function parameter table in the form of value calls.
Input:
Enter two positive integers K m (1
Output:
Output the value of the M entry of the K-order sequence.
Input example:
(Note: All data involved in this question is within the range of long integer data)
Output example:
2 3
Tip:
2
Source:
Code:
#include <stdio.h>#include <stdlib.h>long int charter(int k,int m){ long int PeiBo[m]; if(k<=m) { int i,j; PeiBo[0]=0; for(i=1;i<=m+1;i++) { PeiBo[i]=0; } PeiBo[k]=1; for(j=k+1;j<=m+1;j++) { for(i=1;i<=k;i++) { PeiBo[j]=PeiBo[j]+PeiBo[j-i]; } } return PeiBo[m+1]; } else { return 0; }}int main(){ int k=0,m=0; scanf("%d%d",&k,&m); long int d; d=charter(k,m); printf("%ld\n",d); return 0;}