| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 84295 | 石茂诤 | 最大公约数(函数) | C++ | Accepted | 1 MS | 268 KB | 391 | 2024-07-15 15:07:59 |
# include<bits/stdc++.h> # include<cmath> using namespace std; int a(int n,int m){ for(int i=n;i>0;i--){ if(n%i==0&&m%i==0){ return i; } } } int g(int n,int m){ int c=n%m; while(c!=0){ n=m; m=c; c=n%m; } return m; } int main (){ int n,m; cin>>n>>m; if(n==m){ cout<<n; return 0; } cout<<a(n,m)<<"\n"; //cout<<g(n,m)<<"\n"; return 0; }