7 条题解

  • 3
    @ 2025-3-9 21:26:01

    主函数才两行

    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e5+5,INF=0x3f3f3f3f;
    typedef long long LL;
    int n,m; 
    int main()
    {
    	while(cin>>n>>m)cout<<__gcd(n,m)<<" "<<n/__gcd(n,m)*m<<endl;
    	return 0;
    }
    
    
  • 1
    @ 2026-10-16 20:20:57
    
    #include<iostream>
    #include<algorithm>
    #include<math.h>
    #include<cstdio>
    #include<string.h>
    #include<cctype>
    #include<cmath>
    #include<iomanip>
    #include<stdio.h>
    using namespace std;
    int gcd(int a,int b)
    {
    	while(b!=0)
    	{
    		int temp=b;
    		b=a%b;
    		a=temp;
    	}
    	return a;
     } 
    int lcm(int a,int b)
    {
    	return (a*b)/gcd(a,b);
    }
    int main()
    {
    	int m,n;
    	while(cin>>m>>n)
    	{
    		int g=gcd(m,n);
    		int l=lcm(m,n);
    		cout<<g<<" "<<l<<endl;
    	}
    	
    	return 0;
    }
    
    
    
    • 1
      @ 2022-7-6 21:01:03
      /*****************************************
      备注:
      ******************************************/
      #include <math.h>
      #include <stdio.h>
      #include <iostream>
      #include <string.h>
      using namespace std;
      int main()
      {
      	int a,b;
      	while(cin >> a >> b)
      	{
      		int sum = a* b;
      		while(b != 0)  // 辗转相除法
      		{
      			int r = a%b;
      			a = b;
      			b = r;
      		}
      		cout << a << " " << sum/a << endl;;
      	}
      
      
      }
      
      • -2
        @ 2025-8-10 21:28:44
        #include<bits/stdc++.h>
        using namespace std;
        int n,m,a,b,c;
        int main(){
        	while(cin >> n >> m){
        		a=n;
        		b=m;
        		int ans=m;
        		while(a%b!=0) {
        			c=a%b;
        			a=b;
        			b=c;
        		}
        		cout << b << " " << n*m/(b) << "\n";
        	} 
        	return 0;
        }
        
        
        
        • -6
          @ 2024-11-16 11:35:40
          #include<bits/stdc++.h>
          using namespace std; 
          int main(){
          	int a,b,c,d;
          	while(cin>>a>>b){
          		c=a%b;
          		d=a*b;
          		while(c!=0){
          			a=b;
          			b=c;
          			c=a%b;
          		}
          		cout<<b<<" "<<d/b<<endl;
          	}
          }
          
          • -7
            @ 2023-5-1 15:28:57
            #include<algorithm>
            using namespace std;
            int main(){
            	int m,n;
            	while(cin >>m>>n){
            		int sum = m*n;
            		while (n!=0){
            			int y=m%n;
            			m=n;
            			n=y; 
            		}
            		cout << m << " " << sum/m << endl;
            		
            	}
            	
            	return 0;
            }
            
            • -8
              @ 2023-5-27 13:50:05

              #include #include #include #include #include #include #include #include using namespace std; const int INF = 0x3f3f3f3f; int main() { int a , b; while(cin >> a >> b) { int sum = a * b; while(b != 0) { int r = a % b; a = b; b = r; } cout << a << " " << sum / a << endl; } return 0; }

              • 1

              信息

              ID
              977
              时间
              1000ms
              内存
              128MiB
              难度
              6
              标签
              递交数
              934
              已通过
              254
              上传者