D - Blue and Red Balls(atcoder) 排列组合+组合数取模

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 400 points

Problem Statement

There are KK blue balls and N−K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.

First, Snuke will arrange the N balls in a row from left to right.

Then, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive blue balls. He will collect all the blue balls in the fewest moves possible.

How many ways are there for Snuke to arrange the N balls in a row so that Takahashi will need exactly i moves to collect all the blue balls? Compute this number modulo 109+7 for each ii such that 1≤i≤K

Constraints

  • 1≤K≤N≤2000

Input

Input is given from Standard Input in the following format:

N K

Output

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>双色球拟开奖系统</title> <style> /* 核心样式 */ .container { text-align: center; margin: 20px auto; max-width: 800px; font-family: Arial, sans-serif; } .balls-container { margin: 20px; min-height: 60px; } .ball { display: inline-block; width: 40px; height: 40px; line-height: 40px; border-radius: 50%; margin: 5px; font-weight: bold; opacity: 0; transform: scale(0.5); transition: all 0.5s ease-out; } .ball.show { opacity: 1; transform: scale(1); } .red-ball { background: #ff4444; color: white; } .blue-ball { background: #4444ff; color: white; } #startBtn { padding: 12px 24px; font-size: 18px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background 0.3s; } #startBtn:hover { background: #45a049; } #startBtn:disabled { background: #cccccc; cursor: not-allowed; } </style> </head> <body> <div class="container"> <h2>🎱 双色球拟开奖系统</h2> <button id="startBtn" onclick="startLottery()">开始摇号</button> <div class="result-area"> <div id="redBalls" class="balls-container"></div> <div id="blueBall" class="balls-container"></div> </div> </div> <script> // 红球生成算法(无重复) function generateRedBalls() { const balls = new Set() while(balls.size < 6) { balls.add(Math.floor(Math.random() * 33) + 1) } return [...balls].sort((a,b) => a - b) } // 蓝球生成算法 function generateBlueBall() { return Math.floor(Math.random() * 16) + 1 } // 动画显示逻辑 function startLottery() { const btn = document.getElementById('startBtn') btn.disabled = true btn.textContent = '摇号中...' // 清空上次结果 document.getElementById('redBalls').innerHTML = '' document.getElementById('blueBall').innerHTML = '' // 生成新号码 const reds = generateRedBalls() const blue = generateBlueBall() // 红球逐个显示 reds.forEach((num, index) => { setTimeout(() => { const ball = document.createElement('div') ball.className = 'ball red-ball' ball.textContent = num.toString().padStart(2, '0') document.getElementById('redBalls').appendChild(ball) // 触发动画 setTimeout(() => ball.classList.add('show'), 10) }, 500 * index) }) // 蓝球延迟显示 setTimeout(() => { const ball = document.createElement('div') ball.className = 'ball blue-ball' ball.textContent = blue.toString().padStart(2, '0') document.getElementById('blueBall').appendChild(ball) setTimeout(() => { ball.classList.add('show') btn.disabled = false btn.textContent = '重新摇号' }, 10) }, 500 * reds.length + 1000) } </script> </body> </html> 以上面的代码为基础,增加以下功能:机选任意注并打出这些号码组合
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值