Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

第四题

Posted by 346248129 at 2008-09-20 09:03:57
TimeLimit : 5 Second   Memorylimit : 32 Megabyte   

Totalsubmit : 0   Accepted : 0

Given an infinite array of integers 2,3,.... Now do some operations on it. 

The operation is to choose a minimum number from the array which is never been chosen, then change the status of its multiples excluding itself, i.e remove the multiples of the chosen number if they are in the array , otherwise add it to the array.keep the order after change. 

For instance, the first step, choose number 2, change the status of 4, 6, 8, 10... They are all removed from the array. The second step, choose 3, change the status of 6, 9, 12, 15... 

Pay attention: 9 and 15 are removed from the array while 6 and 12 are added to the array. 

Input 

Every line contains an integer n. The zero value for n indicates the end of input. 

Output 

Print "yes" or "no" according whether n is in the array. 

Sample Input 

2
30
90
0 

Sample Output 

yes
yes
no 

Hint:The number n never has a factor greater than 13000000, but n may be extremely large. 


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator