当前位置:网站首页>【暑期每日一题】洛谷 P1192 台阶问题
【暑期每日一题】洛谷 P1192 台阶问题
2022-08-02 06:07:00 【AC_Dragon】
题目链接:P1192 台阶问题 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目描述
有 N 级的台阶,你一开始在底部,每次可以向上迈最多 K 级台阶(最少 1 级),问到达第 N 级台阶有多少种不同方式。
输入格式
两个正整数N,K。
输出格式
一个正整数,为不同方式数,由于答案可能很大,你需要输出 ans mod 100003 后的结果。
样例 #1
样例输入 #1
5 2样例输出 #1
8提示
对于 20% 的数据,有 N ≤ 10, K ≤ 3;
对于 40% 的数据,有 N ≤ 1000;
对于 100% 的数据,有 N ≤ 100000,K ≤ 100。
AC code:
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll f[N]; // f[n]表示从第1阶台阶到第n阶的走法数
int main()
{
int n,k;
cin>>n>>k;
f[1]=1;
for(int i=2;i<=100000;i++)
{
for(int j=0;j<k;j++)
{
if(1<=i-k+j && i-k+j<i) // if(1<=i-k+j)
f[i]=(f[i]+f[i-k+j])%100003;
}
if(i<=k)
f[i]++;
}
cout<<f[n];
return 0;
} 边栏推荐
- love
- rhce homework
- node安装及环境配置
- Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains
- MySQL高阶---存储引擎、索引、锁
- MySQL 23道经典面试吊打面试官
- Dataset: A detailed guide to the download link collection of commonly used datasets in machine learning
- 享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世
- MySQL - Multi-table query and case detailed explanation
- Toolbox App 1.25 新功能一览 | 版本更新
猜你喜欢

HCIP 第三天实验

MySql COUNT statistics function explanation

Leetcode Weekly 304

MySQL高级语句(一)

Clapper that can interact with the audience in real time

The second day HCIP

MySQL Advanced Statements (1)

【npm install 报错问题合集】- npm ERR! code ENOTEMPTY npm ERR! syscall rmdir

Specified URL is not reachable,caused by :‘Read timed out

MySQL - Multi-table query and case detailed explanation
随机推荐
2022年7月18日-7月31日(Ue4视频教程和文档,20小时。合计1412小时,剩8588小时)
BGP+MPLS Comprehensive Experiment
数据库概论-MySQL的数据表的基本操作
振兴农村循环经济 和数链串起农业“生态链”
8/1 思维+扩展欧几里得+树上dp
Nacos database configuration
MySQL high-level --- storage engine, index, lock
Not annotated parameter overrides @NonNullApi parameter
MySQL Advanced Statements (1)
MySQL高级语句(一)
MySQL(3)
zabbix auto-discovery and auto-registration
zabbix email alarm and WeChat alarm
Node installation and environment configuration
Specified URL is not reachable,caused by :‘Read timed out
.NET Static Code Weaving - Rougamo Release 1.1.0
nacos源码启动找不到istio包
2022年8月计划,着重ue4视频教程
HCIP day one
Leetcode周赛304