CF837E.Vasya's Function
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya is studying number theory. He has denoted a function f(a, b) such that:
- f(a, 0) = 0;
- f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b.
Vasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found out that calculating this function the way he wants to do that might take very long time. So he decided to ask you to implement a program that will calculate this function swiftly.
瓦西娅正在学习数论。他定义了一个函数 f(a,b),满足:
- f(a,0)=0;
- f(a,b)=1+f(a,b−gcd(a,b)),其中 gcd(a,b) 表示 a 与 b 的最大公约数。
瓦西娅有两个数 x 和 y,他希望计算 f(x,y)。他尝试自己手动计算,却发现按此方式直接计算可能需要非常长的时间。因此,他决定请你编写一个程序来快速计算该函数。
输入格式
The first line contains two integer numbers x and y (1 ≤ x, y ≤ 1012).
第一行包含两个整数 x 和 y(1 ≤ x, y ≤ 1012)。
输出格式
Print f(x, y).
输出 f(x,y)。
输入输出样例
输入#1
3 5
输出#1
3
输入#2
6 3
输出#2
1
输入解题思路,AI测评打分。不知道怎么写?