-
Notifications
You must be signed in to change notification settings - Fork 0
/
number.cpp
61 lines (54 loc) · 814 Bytes
/
number.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int no_zeros(int n)
{
while(n)
{
if(n%10==0)
{
return 0;
}
n=n/10;
}
return 1;
}
int perfect(int n)
{
int temp=0;
while(n)
{
temp+=(n%10)*(n%10);
n=n/10;
}
int nu=sqrt(temp);
if(nu*nu==temp)
{
return 1;
}
return 0;
}
int main()
{
int t,n;
cin>>t;
vector<int> ans;
while(t--)
{
cin>>n;
for(int i=pow(10,n-1);i<pow(10,n);i++)
{
if(no_zeros(i)&&perfect(i))
{
ans.push_back(i);
break;
}
}
}
for(auto itr=ans.begin();itr<ans.end();itr++)
{
cout<<*itr<<endl;
}
return 0;
}