6 条题解

  • 1
    @ 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
    @ 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;;
    	}
    
    
    }
    
    • -1
      @ 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;
      }
      
      
      
      • -3
        @ 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;
        	}
        }
        
        • -4
          @ 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; }

          • -4
            @ 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;
            }
            
            • 1

            信息

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