Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
7490 邓小龙 最大公约数(函数) C++ Accepted 0 MS 260 KB 552 2025-05-02 23:58:08

Tests(10/10):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() 、 using namespace std; int my_sum(int x,int y){ int ans=0,j=0; while(x%y!=0){ ans=y; j=x/y; y=x%y; x=ans; } return y; } int main(){ int n,m; cin>>n>>m; if(n-m>m-n) cout<<my_sum(n,m)<<endl; if(n-m<m-n) cout<<my_sum(m,n)<<endl; return 0; }