A10564 | The Wall (medium)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, forming groups, preparing their assault? This must not happen! Quickly, she fetches her HC $^{2}$ (Handbook of Crazy Constructions) and looks for the right chapter:
How to build a wall:
1. Take a set of bricks.
2. Select one of the possible wall designs. Computing the number of possible designs is left as an exercise to the reader.
3. Place bricks on top of each other, according to the chosen design.
This seems easy enough. But Heidi is a Coding Cow, not a Constructing Cow. Her mind keeps coming back to point 2b. Despite the imminent danger of a zombie onslaught, she wonders just how many possible walls she could build with up to $n$ bricks.
A wall is a set of wall segments as defined in the easy version. How many different walls can be constructed such that the wall consists of at least $1$ and at most $n$ bricks? Two walls are different if there exist a column $c$ and a row $r$ such that one wall has a brick in this spot, and the other does not.
Along with $n$ , you will be given $C$ , the width of the wall (as defined in the easy version). Return the number of different walls modulo $10^{6}+3$ .
How to build a wall:
1. Take a set of bricks.
2. Select one of the possible wall designs. Computing the number of possible designs is left as an exercise to the reader.
3. Place bricks on top of each other, according to the chosen design.
This seems easy enough. But Heidi is a Coding Cow, not a Constructing Cow. Her mind keeps coming back to point 2b. Despite the imminent danger of a zombie onslaught, she wonders just how many possible walls she could build with up to $n$ bricks.
A wall is a set of wall segments as defined in the easy version. How many different walls can be constructed such that the wall consists of at least $1$ and at most $n$ bricks? Two walls are different if there exist a column $c$ and a row $r$ such that one wall has a brick in this spot, and the other does not.
Along with $n$ , you will be given $C$ , the width of the wall (as defined in the easy version). Return the number of different walls modulo $10^{6}+3$ .
输入格式
The first line contains two space-separated integers $n$ and $C$ , $1<=n<=500000$ , $1<=C<=200000$ .
输出格式
Print the number of different walls that Heidi could build, modulo $10^{6}+3$ .
输入输出样例
输入 #1
5 1
输出 #1
5
输入 #2
2 2
输出 #2
5
输入 #3
3 2
输出 #3
9
输入 #4
11 5
输出 #4
4367
输入 #5
37 63
输出 #5
230574
输入 #6
8 8 ........ ........ ........ ........ .B...... .B.....B .B.....B .BB...BB
输出 #6
2
The number $10^{6}+3$ is prime.
In the second sample case, the five walls are:
```
<pre class="verbatim"><br></br> B B<br></br>B., .B, BB, B., and .B<br></br>
```
In the third sample case, the nine walls are the five as in the second sample case and in addition the following four:
```
<pre class="verbatim"><br></br>B B<br></br>B B B B<br></br>B., .B, BB, and BB<br></br>
```
In the second sample case, the five walls are:
```
<pre class="verbatim"><br></br> B B<br></br>B., .B, BB, B., and .B<br></br>
```
In the third sample case, the nine walls are the five as in the second sample case and in addition the following four:
```
<pre class="verbatim"><br></br>B B<br></br>B B B B<br></br>B., .B, BB, and BB<br></br>
```
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted