A9524 | Devu and Birthday Celebration
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Today is Devu's birthday. For celebrating the occasion, he bought $n$ sweets from the nearby market. He has invited his $f$ friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to be sad, so he would ensure to give at least one sweet to each friend.
He wants to celebrate it in a unique style, so he would like to ensure following condition for the distribution of sweets. Assume that he has distributed $n$ sweets to his friends such that $i^{th}$ friend is given $a_{i}$ sweets. He wants to make sure that there should not be any positive integer $x>1$ , which divides every $a_{i}$ .
Please find the number of ways he can distribute sweets to his friends in the required way. Note that the order of distribution is important, for example \[1, 2\] and \[2, 1\] are distinct distributions. As the answer could be very large, output answer modulo $1000000007$ $(10^{9}+7)$ .
To make the problem more interesting, you are given $q$ queries. Each query contains an $n$ , $f$ pair. For each query please output the required number of ways modulo $1000000007$ $(10^{9}+7)$ .
He wants to celebrate it in a unique style, so he would like to ensure following condition for the distribution of sweets. Assume that he has distributed $n$ sweets to his friends such that $i^{th}$ friend is given $a_{i}$ sweets. He wants to make sure that there should not be any positive integer $x>1$ , which divides every $a_{i}$ .
Please find the number of ways he can distribute sweets to his friends in the required way. Note that the order of distribution is important, for example \[1, 2\] and \[2, 1\] are distinct distributions. As the answer could be very large, output answer modulo $1000000007$ $(10^{9}+7)$ .
To make the problem more interesting, you are given $q$ queries. Each query contains an $n$ , $f$ pair. For each query please output the required number of ways modulo $1000000007$ $(10^{9}+7)$ .
输入格式
The first line contains an integer $q$ representing the number of queries $(1<=q<=10^{5})$ . Each of the next $q$ lines contains two space space-separated integers $n$ , $f$ $(1<=f<=n<=10^{5})$ .
输出格式
For each query, output a single integer in a line corresponding to the answer of each query.
输入输出样例
输入 #1
5 6 2 7 2 6 3 6 4 7 4
输出 #1
2 6 9 10 20
For first query: $n=6,f=2$ . Possible partitions are \[1, 5\] and \[5, 1\].
For second query: $n=7,f=2$ . Possible partitions are \[1, 6\] and \[2, 5\] and \[3, 4\] and \[4, 3\] and \[5, 3\] and \[6, 1\]. So in total there are 6 possible ways of partitioning.
For second query: $n=7,f=2$ . Possible partitions are \[1, 6\] and \[2, 5\] and \[3, 4\] and \[4, 3\] and \[5, 3\] and \[6, 1\]. So in total there are 6 possible ways of partitioning.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted