游客 Signup | Login
中文 | En

1831 - 课后习题6.6

通过次数

0

提交次数

0

Time Limit : 1 秒 Memory Limit : 128 MB

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

153
???
???
??? 

Input

Output

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

Examples

Input Format


                        

Output Format


                        

Solution C

#include<stdio.h>
main()
{
	int i,t,a,b,c;
	for(i=100;i<999;i++)
	{
		t=i;
		c=t%10;  t/=10;
		b=t%10;  t/=10;
		a=t%10;  t/=10;
		if(i==(a*a*a+b*b*b+c*c*c))
			printf("%d\n",i);
	}
}

Solution C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    cout<<"153\n370\n371\n407";
    return 0;
}