Martix工作室考核题 —— 2019-3-8 第一题
题目
美国数学家维纳( N wiener)智力早熟,11岁就上了大学
他曾在1935~1936年应邀来中国清华大学讲学
次,他参加某个重要会议,年轻的脸孔引人注目
于是有人询问他的年龄,他回答说
我年龄的立方是个4位数。我年龄的4次方是个6位数
这10个数字正好包含了从0到9这10个数字,每个都恰好出现1次
请你推算一下,他当时到底有多年轻
代码
#include <iostream>
#include <sstream>
using namespace std;
void i2s(int a,string &str)
{
stringstream ss;
ss<<a;
ss>>str;
}
int main ()
{
for(int i=10;i<=32;i++)
{
int year_3=i*i*i;
int year_4=i*i*i*i;
string s1,s2;
i2s(year_3,s1);
i2s(year_4,s2);
string s=s1+s2;
bool temp=true;
for(int j=0;j<=9;j++)
{
if(s.find(j+'0')==string::npos) temp=false;
}
if(temp) cout<<i<<endl;
}
return 0;
}
//18
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步