14: Calculate the three digits that meet the condition, and 14 the three digits that meet the condition.

Source: Internet
Author: User

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 }

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.