http://noi.openjudge.cn/ch0113/14/
"""
1.13 编程基础之综合应用_14求满足条件的3位数
http://noi.openjudge.cn/ch0113/14/
"""
n=int(input())
ans=[]
i=100
while i<=999:
j=1
while j<=i:
if j*j==i:
ge=i%10
shi=i//10%10
bai=i//100
if ge==shi or shi==bai or bai==ge:
ans.append(i)
j+=1
i+=1
print(ans[n-1])
C++代码:
/*
1.13编程基础之综合应用_14求满足条件的3位数
http://noi.openjudge.cn/ch0113/14/
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,ans[1111]={},g,s,b,c=0,temp;
cin>>n;
for(int i=100;i<=999;i++)
{
for(int j=1;j<=i;j++)
{
if(j*j==i)
{
g=i%10;
s=i/10%10;
b=i/100;
if(g==s||s==b||b==g)
{
ans[i]=i;
}
}
}
}
for(int i=1;i<=1111;i++)
{
if(ans[i]!=0)
{
c++;
}
if(c==n)
{
temp=ans[i];
break;
}
}
cout<<temp;
return 0;
}