BestCoder Round #6(1003)hdu4983(欧拉函数)
来源:互联网 发布:带着淘宝混异世txt 编辑:程序博客网 时间:2024/06/07 21:34
Goffi and GCD
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 412 Accepted Submission(s): 34
Problem DescriptionGoffi is doing his math homework and he finds an equality on his text book: gcd(n−a,n)×gcd(n−b,n)=nk .
Goffi wants to know the number of (a,b ) satisfy the equality, if n and k are given and 1≤a,b≤n .
Note: gcd(a,b) means greatest common divisor of a and b .
InputInput contains multiple test cases (less than 100). For each test case, there's one line containing two integers n and k (1≤n,k≤109 ).
OutputFor each test case, output a single integer indicating the number of (a,b ) modulo 109+7 .
Sample Input2 13 2
Sample Output21HintFor the first case, (2, 1) and (1, 2) satisfy the equality.
Goffi is doing his math homework and he finds an equality on his text book:gcd(n−a,n)×gcd(n−b,n)=nk .
Goffi wants to know the number of (a,b ) satisfy the equality, ifn andk are given and1≤a,b≤n .
Note:gcd(a,b) means greatest common divisor ofa andb .
Input contains multiple test cases (less than 100). For each test case, there's one line containing two integersn andk (1≤n,k≤109 ).
For each test case, output a single integer indicating the number of (a,b ) modulo109+7 .
2 13 2
21HintFor the first case, (2, 1) and (1, 2) satisfy the equality.
题意:RT
思路:很容易看出k>2时无解,k=2时一个解,k=1时可以预处理出G(x),表示gcd(i,n)=x的i的个数,这里求G(x)等价于求小于n/x且与之互素的数的个数,然后最后累加
G(x)*G(n/x)即可,其中x是n的因子
0 0
- BestCoder Round #6(1003)hdu4983(欧拉函数)
- HDU4983 Goffi and GCD (欧拉函数求解gcd个数)
- hdu4983 / 枚举约数+欧拉函数
- HDU 5780 BestCoder Round #85 gcd (数论---欧拉函数)
- 欧拉函数之HDU4983 Goffi and GCD
- BestCoder Round #54 (div.2) HDOJ5430 Reflect(欧拉函数+脑洞)
- BestCoder Round #86 1003(尺取法)
- BestCoder Round #15(瞎搞)
- BestCoder Round #91(前两题)
- HDU 5597 GTW likes function(规律+欧拉函数模板题)——BestCoder Round #66(div.1 div.2)
- [BestCoder Round #3] hdu 4908 BestCoder Sequence (计数)
- hdu4908 & BestCoder Round #3 BestCoder Sequence(组合数学)
- hdu 4991 Ordered Subsequence(Bestcoder Round #8 1003)
- BestCoder Round #13 1003(单调性DP)HDU5064
- hdu5429(BestCoder Round #54 (div.2) 1003题)
- BestCoder Round #87(1003-【思维】【LIS&&LCS】)
- BestCoder Round #6(1002)hdu4982(贪心)
- hdu 4956 Poor Hanamichi(bestcoder Round 6 1001)
- C++设计模式从0进击-1-简单(静态)工厂模式
- 一个示例的iptables 脚本
- MySQL-5.6.17免安装版配置方法
- 刘强东:京东因自建物流减少库存周转至32天
- Android listview中再嵌套listview 实现消息评论功能处理
- BestCoder Round #6(1003)hdu4983(欧拉函数)
- 网站的robots 文件写法 附自动生成工具网址
- TCP/IP
- svn相关
- poj 1192 求树的最大权子树(树形dp)
- C/C++中的日期和时间 TIME_T与STRUCT TM转换
- GridView 在包含 ImageButton时,获得焦点
- 游戏《扫雷》开发 用最笨的办法去开发 让每个人都能够明白原理 附赠源码g
- 开源华为Portal协议中间件