当前位置:网站首页>【英雄哥七月集训】第 16天:队列
【英雄哥七月集训】第 16天:队列
2022-07-17 04:54:00 【如果我是温帅帅】
系列文章
一、知道秘密的人数
leetcode2327 java
class Solution {
static final int Mod = (int) 1e9+7;
public int peopleAwareOfSecret(int n, int delay, int forget) {
int[] dp = new int[n+1];
dp[1] = 1;
for(int i = 2;i < n + 1; i++){
for(int j = Math.max(0,i-forget+1);j<=i-delay && j<n+1;j++){
//System.out.printf("%d %d %d %d\n",dp[i],dp[j],i,j);
dp[i]=(dp[i]+dp[j])%Mod;
}
}
int res = 0;
for(int i = n-forget+1;i<=n;i++){
res = (res+dp[i])%Mod;
}
return res;
}
}
总结
边栏推荐
猜你喜欢

C语言动态内存开辟和柔性数组

Week 2022/7/16

Advanced query of MySQL table

T + 0 to t + 1! The quick redemption amount is reduced to 10000! Another bank adjusted the rules for the application and redemption of cash wealth management products

Eureka, take advantage of the tens of millions of daily visits!

Reproduction of XOR and encryption decryption

数据库学习笔记(一)检索数据

使用小丸工具箱进行极限视频压缩

服务端接口测试-接口测试的测试点【杭州多测师】【杭州多测师_王sir】

【TA-霜狼_may-《百人计划》】基础渲染光照介绍(一)
随机推荐
PowerDesigner显示Comment注释
An easy-to-use network liar reporting system without encrypted version source code
深度学习中的标量、向量、矩阵和张量的区别
word使用技巧
[TA frost wolf \u may - hundred people plan] Figure 2.5 bump mapping
Week 2022/7/16
tf.AUTO_REUSE的作用
C language dynamic memory development and flexible array
Practice and improvement of children's network protection industry based on mobile Internet application
Unity UMP打包黑屏問題總結
Delete the file unable to find or create trash directory
Advanced query of MySQL table
Using everything to clean up junk files
复旦微FMQL(国产Zynq) 【IAR裸机开发之PS】——非字节对齐访问
Wechat applet source code of high imitation Netease cloud music UI
Cannot find module ‘process‘ or its corresponding type declarations.
网址在线封装APK系统源码
MySQL中判断和向下取整的使用场景和用法
Kettle5.4 problem record
Codeforces Round #419 (Div. 1)B - Karen and Test