A10562 | The Wall (hard)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
So many wall designs to choose from! Even modulo $10^{6}+3$ , it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do something to narrow them down.
Heidi is quick to come up with criteria for a useful wall:
- In a useful wall, at least one segment is wider than $W$ bricks. This should give the zombies something to hit their heads against. Or,
- in a useful wall, at least one column is higher than $H$ bricks. This provides a lookout from which zombies can be spotted at a distance.
This should rule out a fair amount of possibilities, right? Help Heidi compute the number of useless walls that do not confirm to either of these criteria. In other words, a wall is useless if every segment has width at most $W$ and height at most $H$ .
Parameter $C$ , the total width of the wall, has the same meaning as in the easy version. However, note that the number of bricks is now unlimited.
Output the number of useless walls modulo $10^{6}+3$ .
Heidi is quick to come up with criteria for a useful wall:
- In a useful wall, at least one segment is wider than $W$ bricks. This should give the zombies something to hit their heads against. Or,
- in a useful wall, at least one column is higher than $H$ bricks. This provides a lookout from which zombies can be spotted at a distance.
This should rule out a fair amount of possibilities, right? Help Heidi compute the number of useless walls that do not confirm to either of these criteria. In other words, a wall is useless if every segment has width at most $W$ and height at most $H$ .
Parameter $C$ , the total width of the wall, has the same meaning as in the easy version. However, note that the number of bricks is now unlimited.
Output the number of useless walls modulo $10^{6}+3$ .
输入格式
The first and the only line of the input contains three space-separated integers $C$ , $W$ and $H$ ( $1<=C<=10^{8}$ , $1<=W,H<=100$ ).
输出格式
Output the number of different walls, modulo $10^{6}+3$ , which are useless according to Heidi's criteria.
输入输出样例
输入 #1
1 1 1
输出 #1
2
输入 #2
1 2 2
输出 #2
3
输入 #3
1 2 3
输出 #3
4
输入 #4
3 2 2
输出 #4
19
输入 #5
5 4 9
输出 #5
40951
输入 #6
40 37 65
输出 #6
933869
If there is no brick in any of the columns, the structure is considered as a useless wall.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted