[Problem solution] Luogu P1192 step problem

Go to: My own blog

topic

Luogu P1192 step problem

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100000+5;
const int MOD=100003;
int n,k;
int f[maxn];

int main()
{
	scanf("%d%d",&n,&k);
	f[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=k;j++)
			if(i-j>=0) f[i]=(f[i]+f[i-j])%MOD;
	printf("%d\n",f[n]);
			
	return 0;
}

Guess you like

Origin blog.csdn.net/zjgmartin/article/details/108415907