luogu P1192 Step problem

P1192
topic description
There are NN steps. You are at the bottom at the beginning. You can step up to KK steps (at least 11 steps) each time. Ask how many different ways there are to reach the NN step.

Input format
Two positive integers N and K.

Output format
A positive integer, which is a number in different ways. Since the answer may be large, you need to output the result after ans \bmod 100003 and ansmod100003.

Input and output sample
input #1 copy
5 2
output #1 copy
8
Description/prompt
For 20% 20% of the data, there are N ≤ 10, K ≤ 3, N ≤ 10, K ≤ 3;

For 40% 40% of data, N ≤ 1000 N ≤ 1000;

For 100% 100% data, N ≤ 100000, K ≤ 100N ≤ 100000, K ≤ 100.

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int main(){
    
    
	ll n,k,p=100003,num[100009]={
    
    };//范围写100000你也写的出来??!! 
	cin>>n>>k;
	num[0]=0,num[1]=1;
	for(int i=2;i<=k;i++){
    
    
		num[i]=num[i-1]*2%p;
	}
	for(int i=k+1;i<=n;i++){
    
    
		for(int j=i-1;j>=i-k;j--)
		num[i]+=num[j]%p;
		num[i]%=p;
	}
	cout<<num[n]%p;
	return 0;
	
}

Guess you like

Origin blog.csdn.net/Minelois/article/details/113873713