タイトル
分析
- 再発
- 当1-k f[i]=i+1;
- > KF [I] = F [I-1] + F [IK-1]
コード
1の#include <cmath> 2の#include <cstdioを> 3の#include <CStringの> 4の#include <iostreamの> 5の#include <アルゴリズム> 6 のconst int型 MOD = 5000011 。 7 使用して 名前空間はstdを、 8 int型 F [ 100001 ]。 9 INT メイン(){ 10 int型N、K。 11 のscanf(" %D%dの"、&N&K)。 12 のために(int型 I = 0 ; iが<= N; iが++ ) 13 { 14 ならば(私は= K <)F [I] = I + 1 。 15 他 F [I] =(F [I- 1 ] + F [ik- 1 ])%MOD。 16 } 17 COUT << F [N]。 18 リターン 0 。 19 }