1 solutions

  • 0
    @ 2025-3-3 16:33:59

    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",p/n);        // p是原来两个整数的乘积
     return 0;
     } 
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int M,N;
    	cin>>M>>N;
    	int x=0;
    	for(int i=1;i<=9999;i++){
    		int m=M*i;
    			if(m%N==0){
    				x=m;
    				break;
    			}
    	}
    	cout<<x<<endl;
    } 
    

    Python :

    a, b = map(int, input().split())
    for i in range(1,(a * b)+1):
            if i % a == 0 and i % b == 0:
                print(i)
                break;
    
    
    • 1

    Information

    ID
    10832
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By