题解 | #变种水仙花#
变种水仙花
https://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71
#include <stdio.h> //思路: //用/和%这两个符号对整数进行分割,分割成两个新的整数后再进一步计算,最后判断它所有分割后的两个数的乘积的和是否等于原来的数 #include <stdio.h> int main() { int n = 0; for (n = 10000; n <= 99999; n++) { int sum = 0; int j = 10; for (j = 10; j <= 10000; j =10*j) { sum += (n / j) * (n % j); } if (sum == n) { printf("%d ", n); } } return 0; }