2728 integer empire problem, 2728 integer empire

Source: Internet
Author: User

2728 integer empire problem, 2728 integer empire
2728 integer empire Problems

 

Time Limit: 1 s space limit: 16000 KB title level: Silver Title Description Description

A long time ago, there was an integer empire in the distant East, which had a large number of positive integers, alleviating the housing pressure of the capital city, emperor alistin wants to migrate some "useless" positive integers out of the city. But how can we determine that the positive integers are "useless? The king was so worried that he could not sleep at night.

The smart Prime Minister kruso proposed that if all integers except 1 can be expressed as a * B, and both a and B are positive integers, this number is useless. For example, 120 can be expressed in the form of 2 × 60, so 120 is "useless", while 13 does not have any form of a * B except 1 × 13, therefore, 13 is not useless. Now, you only need to determine whether a positive integer n is "useless ".

The King thinks this proposal is excellent, so he handed over the important task of maintaining the peace and stability of the capital, because you are the Chief Information Security Expert of the integer empire. (This is too Headless ......)

You must deal with it as soon as possible, because it was ancient times, and dereliction of duty was to be hacked!

Input description Input Description

Only one row of input data contains a positive integer n.

Output description Output Description

Only one row of output data. If this number is useless, "Yes!" Is output !"

If it is useful, output "No !"

Sample Input Sample Input

120

Sample output Sample Output

Yes!

Data range and prompt Data Size & Hint

1 <n <= 1000000

A, B> 1

CATEGORY tag Tags click here to expand

Question:> prime number determination

 1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 using namespace std; 5 const int MAXN=10000001; 6 int vis[MAXN]; 7 int main() 8 { 9     int n;10     scanf("%d",&n);11     for(int i=2;i<=sqrt(n);i++)12     {13         if(vis[i]==0)14         {15             for(int j=i*i;j<=n;j=j+i)16             {17                 vis[j]=1;18             }19         }20     }21     if(vis[n]==0)22     {23         printf("No!");24     }25     else 26     {27         printf("Yes!");28     }29     return 0;30  } 

 

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.