1 条题解

  • 0
    @ 2023-6-11 12:17:10

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int g,s,b,q,w,i,s1,s2,s3,k,f = 0;
    	cin>>k;
    	for(i = 10000;i <= 30000;i++){
    		w = i / 10000;
    		q = i / 1000 % 10;
    		b = i / 100 % 10;
    		s = i / 10 % 10;
    		g = i % 10;
    		
    		s1 = w * 100 + q * 10 + b;
    		s2 = q * 100 + b * 10 + s;
    		s3 = b * 100 + s * 10 + g;
    		
    		if(s1 % k == 0 && s2 % k == 0 && s3 % k == 0){
    			cout<<i<<endl;
    			f = 1;
    		}
    	}
    	
    	if(f == 0){
    		cout<<"No"<<endl;
    	}
    }
    
    
    

    Python :

    k=int(input())
    s=0
    for i in range(10000,30001):
        a=i//100
        b=i//10%1000
        c=i%1000
        if a%k==0 and b%k==0 and c%k==0:
            s+=1
            print(i)
    if s==0:         
        print('No')
    
    • 1

    信息

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