A9840 | Darth Vader and Tree
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
When Darth Vader gets bored, he sits down on the sofa, closes his eyes and thinks of an infinite rooted tree where each node has exactly $n$ sons, at that for each node, the distance between it an its $i$ -th left child equals to $d_{i}$ . The Sith Lord loves counting the number of nodes in the tree that are at a distance at most $x$ from the root. The distance is the sum of the lengths of edges on the path between nodes.
But he has got used to this activity and even grew bored of it. 'Why does he do that, then?' — you may ask. It's just that he feels superior knowing that only he can solve this problem.
Do you want to challenge Darth Vader himself? Count the required number of nodes. As the answer can be rather large, find it modulo $10^{9}+7$ .
But he has got used to this activity and even grew bored of it. 'Why does he do that, then?' — you may ask. It's just that he feels superior knowing that only he can solve this problem.
Do you want to challenge Darth Vader himself? Count the required number of nodes. As the answer can be rather large, find it modulo $10^{9}+7$ .
输入格式
The first line contains two space-separated integers $n$ and $x$ ( $1<=n<=10^{5},0<=x<=10^{9}$ ) — the number of children of each node and the distance from the root within the range of which you need to count the nodes.
The next line contains $n$ space-separated integers $d_{i}$ ( $1<=d_{i}<=100$ ) — the length of the edge that connects each node with its $i$ -th child.
The next line contains $n$ space-separated integers $d_{i}$ ( $1<=d_{i}<=100$ ) — the length of the edge that connects each node with its $i$ -th child.
输出格式
Print a single number — the number of vertexes in the tree at distance from the root equal to at most $x$ .
输入输出样例
输入 #1
3 3 1 2 3
输出 #1
8
Pictures to the sample (the yellow color marks the nodes the distance to which is at most three)


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted