[Number] Number of children Integer

Link——————————————

It is the topic of Dongguan Special Longevity in 2016.



solution

This... introductory questions, just enumerate.


Code

#include<cstdio>
int k, a, b, c, ans;
int main(){
    
    
	scanf("%d", &k);
	for(int i = 10000; i <= 30000; ++i){
    
    
		a = i / 100; 
		b = i % 10000 / 10; 
		c = i % 1000;
		if(a % k == 0 && b % k == 0 && c % k == 0){
    
    
			++ans;
			printf("%d\n", i);
		}
	}
	if(ans == 0) printf("No");
} 

Guess you like

Origin blog.csdn.net/qq_42937087/article/details/115026719