1 条题解

  • 0
    @ 2025-4-27 18:44:58

    C :

    #include<stdio.h>
    void main()
    {
    	int a,b,c,d,e,i=0;
    	for(a=1;a<=9;a++)
    		for(b=1;b<=9;b++)
    			for(c=1;c<=9;c++)
    				for(d=1;d<=9;d++)
    					for(e=1;e<=9;e++)
    						if(a!=b&&b!=c&&c!=d&&d!=e&&a!=c&&a!=d&&a!=e&&b!=d&&b!=e&&c!=e){
    								if((10*a+b)*(100*c+10*d+e)==(100*a+10*d+b)*(10*c+e)){
    								i++;
    							}
    						}
    						
    		printf("%d\n",i);						
    								 
     } 
    

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int a,b,c,d,e;
    	int n=0;
    	for( a=1;a<=9;a++){
    		for(b=1;b<=9;b++){
    			for(c=1;c<=9;c++){
    				for(d=1;d<=9;d++){
    					for(e=1;e<=9;e++){
    						if(a!=b&&a!=c&&a!=d&&a!=e&&b!=c&&b!=d&&b!=d&&b!=e&&c!=d&&c!=e&&d!=e){
    							if((a*10+b)*(c*100+d*10+e)==(a*100+d*10+b)*(c*10+e) ){
    								n++;
    							}
    						}
    					}	
    				}
    			 }	
    		}
    	}
    	cout<<n<<endl;
    	
    	return 0;
    } 
    

    Java :

    public class Main {
    	public static void main(String[] args) {
    		int a, b, c, d, e;
    	    int i = 0;
    	    for(a = 1; a <= 9; a++)
    	    {
    	        for(b = 1; b <= 9; b++)
    	        {
    	            if(b != a)
    	            for(c = 1; c <= 9; c++)
    	            {
    	                if(c != b && c !=a)
    	                for(d = 1; d <= 9; d++)
    	                {
    	                    if(d != a && d != b && d != c)
    	                    for(e = 1; e <= 9; e++)
    	                    {
    	                        if(e != a && e != b && e != c && e != d && (10 * a + b) * (100 * c + 10 * d + e) == (100 * a + 10 * d + b) *  (10 * c + e))
    	                        {
    	                            i++;
    	                            
    	                        }
    	                    }
    	                }
    	            }
    	        }
    	    }
    	    System.out.println(i);
    	    return ;
    	}
    			
    		
    	}
    

    Python :

    t = 0
    for a in range(1, 10):
        for b in range(1, 10):
            for c in range(1, 10):
                for d in range(1, 10):
                    for e in range(1, 10):
                        if(int(str(a) + str(b)) * int(str(c) + str(d) + str(e)) == int(str(a) + str(d) + str(b)) * int(str(c) + str(e))):
                            if(a != b and a != c and a != d and a != e):
                                if(b != c and b != d and b != e):
                                    if(c != d and c != e):
                                        if(d != e):
                                            t += 1
    print(t)
    
    • 1

    信息

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