64,654
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long lint;
class A{
lint s; //value
static unsigned len; //数长
public:
A():s(0){} //
A& operator=(lint n){ //
s = n; // 重载赋值
len = 0; //初始化长度
if (chk()) cout<<"水仙花"<<ends<<s<<endl;
len = 0; //复位长度
return *this;
}
inline operator lint(){return s;} //类型转换
bool chk(){return (ast(s)-s)?0:1;} //检测是否为百合
static lint ast(lint bb){ //递归实现数分解与幂累积
++len;
lint _tmp = 0;
if(bb/10) _tmp = ast(bb/10);
return _tmp=_tmp+pow(bb%10,len);
}
static lint pow(lint x,lint y){ //pow函数
lint _tmp = 1;
for (int i = 0;i<y;i++) _tmp *=x;
return _tmp;
}
};
unsigned A::len = 0;
istream& operator>>(istream &c,A &t){ //重载>>
lint l;
c>>l;
t=l; //重载A::=
return c;
}
int main()
{
A x;
for (lint i = 1;i<999999;i++)x=i; //六位数的水仙花
do {
cin.sync();
cin.clear();
cin>>x;
} while(x!=0||cin.fail()); //输入零退出
}
#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long lint;
class A{
lint s; //value
static unsigned len; //数长
public:
A():s(0){} //
A& operator=(lint n){ //
s = n; // 重载赋值
len = 0; //初始化长度
if (chk()) cout<<"水仙花"<<ends<<s<<endl;
len = 0; //复位长度
return *this;
}
inline operator lint(){return s;} //类型转换
bool chk(){return (ast(s)-s)?0:1;} //检测是否为百合
static lint ast(lint bb){ //递归实现数分解与幂累积
++len;
lint _tmp = 0;
if(bb/10) _tmp = ast(bb/10);
return _tmp=_tmp+pow(bb%10,len);
}
static lint pow(lint x,lint y){ //pow函数
lint _tmp = 1;
for (int i = 0;i<y;i++) _tmp *=x;
return _tmp;
}
};
unsigned A::len = 0;
istream& operator>>(istream &c,A &t){ //重载>>
lint l;
c>>l;
t=l; //重载A::=
return c;
}
int main()
{
A x;
for (lint i = 1;i<999999;i++)x=i; //六位数的水仙花
do {
cin.sync();
cin.clear();
cin>>x;
} while(x!=0||cin.fail()); //输入零退出
}