作者:yunjinqi 类别:
日期:2023-05-31 10:25:55
阅读:458 次 消耗积分:0 分
#include <stdio.h>
#include <math.h>
int gn(int a,int n){
int sum=1;
for (int i=0;i<n;i++){
sum*=a;
}
return sum;
}
int main(){
int N;
int num=0;
if (scanf("%d",&N)!=EOF){
// 计算满足的最大的数字
num = gn(10,N);
num = num-1;
// printf("num = %d\n",num);
// 根据计算出来的数字,看数字本身是否满足
for (int j=gn(10,N-1);j<=num;j++){
int new_num = 0;
int copy_num = j;
int s;
while (copy_num>0){
s = copy_num%10;
copy_num = copy_num/10;
new_num += gn(s,N);
if (new_num>j){break;}
}
// printf("%d %d\n",j,new_num);
if (new_num==j){printf("%d\n",j);}
}
}else{
printf("input wrong");
}
return 0;
}