CF837E.Vasya's Function
普及/提高-
通过率:0%
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.
输入格式
The first line contains two integer numbers x and y ( 1<=x,y<=1012 ).
输出格式
Print f(x,y) .
输入输出样例
输入#1
3 5
输出#1
3
输入#2
6 3
输出#2
1