1 条题解
-
0
C :
#include <stdio.h> int main () {int p,r,n,m,temp; scanf("%d %d",&n,&m); if (n<m) {temp=n; n=m; m=temp; //把大数放在n中, 小数放在m中 } p=n*m; //先将n和m的乘积保存在p中, 以便求最小公倍数时用 while (m!=0) //求n和m的最大公约数 {r=n%m; n=m; m=r; } printf("%d",n); return 0; }
C++ :
#include <iostream> #include <iomanip> using namespace std; int main(){ int a,b,i; cin>>b>>a; for(i=a;i>=1;i--){ if(a%i==0&&b%i==0){ cout<<i<<endl; break; } } }
Python :
a, b = map(int, input().split()) if a < b: a, b = b, a; x = a % b; while x != 0: a = b b = x x = a % b print(b)
- 1
信息
- ID
- 10842
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者