提交时间:2023-10-07 13:50:36
运行 ID: 105663
#include<bits/stdc++.h> using namespace std; unsigned long long f(unsigned long long n,unsigned long long m) { unsigned long long s=(n/m+m/n-(n==m)); if(max(n,m)==n) n-=(n/m)*m; else m-=(m/n)*n; if(n>0&&m>0) s+=f(n,m); return s; } int main() { unsigned long long n,m; cin>>n>>m; cout<<f(n,m); return 0; }