1 solutions
-
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
Information
- ID
- 10842
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By