Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
84296 刘宇轩 最大公约数(函数) C++ Accepted 1 MS 272 KB 312 2024-07-15 15:08:04

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; /*int d(int b,int c){ for(int i=b;i>=0;i--){ if(b%i==0&&c%i==0){ return i; } } }*/ int d(int b,int c){ int n=b%c; while(n!=0){ b=c; c=n; n=b%c; } return c; } int main(){ int a,b; cin>>a>>b; cout<<d(a,b); return 0; }