1 solutions

  • 0
    @ 2025-3-3 16:29:42

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	long long f[10] = {0};//存放0~9之间是否都出现了
    	long long c = 0;//存放1~9之间出现了几个数
    	long long n,k = 0,x,t,r;
    	cin>>n;
    	
    	t = 1;//从1开始乘
    	//1~9如果还没都出现
    	while(c < 9){
    		k = n * t;
    		r = k;
    		while(k != 0){
    			x = k % 10;
    			k = k / 10;
    			//如果x还没出现,标记为出现了
    			if(x > 0 && f[x] == 0){
    				c++;
    				f[x] = 1;
    			} 
    		}
    		t++;
    	}
    	
    	cout<<r;
    	
    	return 0;
    }
    
    

    Python :

    n=int(input())
    a=[0 for i in range(9)]
    js=0
    while(a.count(1)<9):
        js=js+1
        m=n*js
        m1=m
        while(m1>0):
            k=m1%10
            if(k!=0):
                a[k-1]=1
            m1=m1//10
    print(m)
    
    • 1

    Information

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