时间限制:1000ms
占用内存:65535KB
题目描述:输入正整数N,判断它是不是一个四叶玫瑰数,输出YES或者NO。四位玫 瑰数是4位 数的自幂数,它的每个位上的数字的4次幂之和等于它本身。
输入格式:输入正整数N
输出格式:输出YES或者NO
样例输入:1634
样例输出:YES
参考程序:C++
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
int d,t,sum=0;
scanf("%d", &d);
if (d < 1000 || d>9999) {
printf("NO\n");
return 0;
}
t = d;
while (t >= 10) {
int n = t % 10;
sum += pow(n, 4);
t = t / 10;
}
sum += pow(t, 4);
if (int(sum) == d)
printf("YES\n");
else
printf("NO\n");
return 0;
}
题目来源:码蹄集
https://matiji.net/exam/brushquestion/170/778/B3FCFEC101BD05189BB74D522E019504