1151:0 start-up algorithm 58--turn on the light problem

Source: Internet
Author: User

1151:0 start-up algorithm 58--open light problem time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:3195 accepted:1445
[Submit] [Status] [Web Board] Description

The computing Center has 8 computer rooms, each with n computers. Each computer has a number, such as the number of room 8th is H1 to HN, we sometimes called the H1 machine 1th, H2 for the number 2nd machine,...。
One day our school ranked among the top 100 universities in the world, and all the teachers and students had a carnival celebration. Mr. Luo is a very refreshing person, also like drinking, he drank a little more that day. But unfortunately, that night, Mr. Luo is on duty, teacher Luo is a very responsible teacher. So he opened the room number 8th. But the students are still partying, no one to get on the machine. Mr. Luo, carrying a bottle of wine, felt very bored, so he wanted to play a game.
In the first round, he drank a mouthful of wine, and he turned on all the computers. Then the second round he took a sip of wine, he put the number is 2,4,6,... Computer is all shut down. In the third round, he drank a drink and went to operate all the numbers are 3,6,9, ..., see the computer turned on and turn it off, see the computer turned off and turn it on. He repeats this operation for a total of n rounds. When he finished the last round, Mr. Luo fell drunk.
Now give you the number of computers in this computer room, ask you how many computers are open in the end?

Input

Multiple sets of data tests.

Input is only 1 lines, this line has a positive integer, indicating how many computers in this computer room, the number is any positive integer between 5 and 100.

Output

You must output the last number of computers that are open. Do not forget to change the line after outputting the number

Sample Input
5

Sample Output
2

HINT


for (i=1;i<=n;i++)//i represents the Turn 1--n

for (k=1;k<=n;k++)//k represents the computer number 1--n


Source

0 Starting point Learning algorithm

1#include <stdio.h>2 intMain () {3     intn,a[ -];4      while(SCANF ("%d", &n)! =EOF) {5          for(intI=1; i<=n;i++){6a[i]=0; 7         }8     9      for(intI=1; i<=n;i++){Ten          for(intj=i;j<=n;j+=i) { One             if(a[j]==0) Aa[j]=1; -             Else -a[j]=0; the          -         } -          -     } +     intnum=0; -      for(intI=1; i<=n;i++){ +         if(a[i]==1) Anum++; at     } -printf"%d\n", num); -     } -     return 0; -}

1151:0 start-up algorithm 58--turn on the light problem

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.