14: Calculate the three digits that meet the condition, and 14 the three digits that meet the condition.
14: Calculate the three digits that meet the condition
- View
- Submit
- Statistics
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Write a program to search for all three digits that meet both conditions 1 and 2 in ascending order. The condition is:
1. This number is the total number of shards.
2. The number must have at least two digits.
For example, 100 meets both of the preceding conditions.
-
Input
-
Enter the number n and n of three digits that meet the conditions.
-
Output
-
The output is the nth three-digit value that meets the condition (ascending)
-
Sample Input
-
1
-
Sample output
-
100
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstring> 5 using namespace std; 6 int tot; 7 int i=99; 8 int a[11]; 9 int main()10 {11 int n;12 cin>>n;13 while(tot<n)14 {15 memset(a,0,sizeof(a));16 if(sqrt(i)!=ceil(sqrt(i)))17 {18 i++;19 continue;20 }21 int c=i;22 int now=0;23 while(c!=0)24 {25 a[c%10]++;26 if(a[c%10]>=2)27 {28 tot++;29 if(tot==n)cout<<i;30 else i++;31 break;32 }33 else34 c=c/10;35 }36 i++;37 }38 return 0;39 }