1 条题解

  • 0
    @ 2023-6-11 12:20:40

    C :

    #include<stdio.h>
    int main()
    {
        long long m;
        long long n,t;
        scanf("%lld",&m);
        n=m/1000;
        t=m-n*1000;
        if(n>t)
            printf("%lld",m);
        else
            printf("%lld",t*1000+n);
        return 0;
    }
    
    

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int n;
        cin>>n;
    	if(n / 1000 > n % 1000){
    		cout<<n;
    	}else{
    		cout<<n%1000<<n/1000;
    	}
    }
     
    
    

    Java :

    import java.util.Scanner;
    
    public class Main{
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int a = sc.nextInt();
    		int q = a/1000;
    		int h = a%1000;
    		
    		
    		if (q<h) {
    			System.out.println(h*1000+q);
    		}else {
    			System.out.println(q*1000+h);
    		}
    		
    	}
    
    }
    

    Python :

    n = int(input())
    sw = n // 100000 % 10
    w = n // 10000 % 10
    q = n // 1000 % 10
    b = n // 100 % 10
    s = n // 10 % 10
    g = n // 1 % 10
    x = sw * 100 + w * 10 + q
    y = b * 100 + s * 10 + g
    if x > y:
        print(n)
    else:
        print(b * 100000 + s * 10000 + g * 1000 + sw * 100 + w * 10 + q)
    
    
    • 1

    信息

    ID
    2539
    时间
    1000ms
    内存
    64MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者