JDOJ 1139 水仙花数

JDOJ 1139: 水仙花数

https://neooj.com/oldoj/problem.php?id=1139

Description

打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身。例如:153是一个水仙花数,因为153=13+53+33。 Output:

153
???
???
??? 

Input

Output

所有的水仙花数,从小的开始。每行一个

模拟题:

当时蒟蒻的代码特别喜欢头文件。。。

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    int a,b,c;
    for(a=100;a<=999;a++)
    {
        if(pow((a/100),3)+pow((a/10)%10,3)+pow(a%10,3)==a)
        printf("%d\n",a);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/fusiwei/p/11255614.html