6 条题解
- 1
信息
- ID
- 30933
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- (无)
- 递交数
- 218
- 已通过
- 58
- 上传者
#include using namespace std;
int main() { int n; cin >> n; int a = n / 100; //百位 int b = n / 10 % 10; //十位 int c = n % 10; //个位
int sum = a*a*a + b*b*b + c*c*c;
if(sum == n)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
} 水仙花数:百位立方 + 十位立方 + 个位立方 = 原数 例
#include using namespace std;
int main() { int n, a, b, c; int sum = 0; cin >> n; a = n / 100; b = n % 100 / 10; c = n % 10; sum = a * a * a + b * b * b + c * c * c; if (sum == n) { cout << "YES"; } else { cout << "NO"; } return 0; }