CF776E.The Holmes Children

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Holmes children are fighting over who amongst them is the cleverest.

Mycroft asked Sherlock and Eurus to find value of f(n), where f(1) = 1 and for n ≥ 2, f(n) is the number of distinct ordered positive integer pairs (x, y) that satisfy x + y = n and gcd(x, y) = 1. The integer gcd(a, b) is the greatest common divisor of a and b.

Sherlock said that solving this was child's play and asked Mycroft to instead get the value of . Summation is done over all positive integers d that divide n.

Eurus was quietly observing all this and finally came up with her problem to astonish both Sherlock and Mycroft.

She defined a k-composite function F__k(n) recursively as follows:

She wants them to tell the value of F__k(n) modulo 1000000007.

福尔摩斯家的孩子们正在争论,他们之中究竟谁最聪明。

迈克罗夫特让夏洛克和欧洛斯计算函数 $ f(n) $ 的值,其中 $ f(1) = 1 $,而对于 $ n \geq 2 ,, f(n) $ 表示满足 $ x + y = n $ 且 $ \gcd(x, y) = 1 $ 的互异的有序正整数对 $ (x, y) $ 的个数。此处 $ \gcd(a, b) $ 表示 $ a $ 与 $ b $ 的最大公约数。

夏洛克称这道题小菜一碟,于是请迈克罗夫特改为计算 的值。该求和遍历所有能整除 $ n $ 的正整数 $ d $。

欧洛斯一直安静地旁观这一切,最后提出了她自己的问题,以令夏洛克和迈克罗夫特都大为惊叹。

她递归地定义了一个 $ k $-复合函数 $ F_k(n) $,如下所示:

她要求他们计算 $ F_k(n) $ 对 $ 1000000007 $ 取模的结果。

输入格式

A single line of input contains two space separated integers n (1 ≤ n ≤ 1012) and k (1 ≤ k ≤ 1012) indicating that Eurus asks Sherlock and Mycroft to find the value of F__k(n) modulo 1000000007.

一行输入包含两个以空格分隔的整数 nn(1 ≤ n ≤ 10121 \leq n \leq 10^{12})和 kk(1 ≤ k ≤ 10121 \leq k \leq 10^{12}),表示 Eurus 要求 Sherlock 和 Mycroft 计算 Fk(n)F_k(n) 对 10000000071000000007 取模的值。

输出格式

Output a single integer — the value of F__k(n) modulo 1000000007.

输出一个整数——Fk(n)F_k(n) 对 10000000071000000007 取模的结果。

输入输出样例

  • 输入#1

    7 1

    输出#1

    6
  • 输入#2

    10 2

    输出#2

    4

说明/提示

In the first case, there are 6 distinct ordered pairs (1, 6), (2, 5), (3, 4), (4, 3), (5, 2) and (6, 1) satisfying x + y = 7 and gcd(x, y) = 1. Hence, f(7) = 6. So, _F_1(7) = f(g(7)) = f(f(7) + f(1)) = f(6 + 1) = f(7) = 6.

第一种情况中,有 6 个互不相同的有序对 (1, 6)(1,\,6)、(2, 5)(2,\,5)、(3, 4)(3,\,4)、(4, 3)(4,\,3)、(5, 2)(5,\,2) 和 (6, 1)(6,\,1) 满足 x + y = 7x\,+\,y\,=\,7 且 gcd⁡(x, y) = 1\gcd(x,\,y)\,=\,1。因此,f(7) = 6f(7)\,=\,6。于是,F1(7) = f(g(7)) = f(f(7) + f(1)) = f(6 + 1) = f(7) = 6F_1(7)\,=\,f(g(7))\,=\,f(f(7)\,+\,f(1))\,=\,f(6\,+\,1)\,=\,f(7)\,=\,6。

输入解题思路,AI测评打分。不知道怎么写?

首页