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 dongfangyuxiao at 2011-05-05 12:58:13 on Problem 1003
import java.util.Scanner;
public class Solve1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	   Scanner scan=null;	
	   double c;
	   int i;
	   scan=new Scanner(System.in);	
	  while(scan.hasNext())	
	   {	
		
	     c=scan.nextDouble();	
	     if(c==0.0)
	    	 break;
		 for( i=1;;i++)
				if(newSum(i)>=c)
			     break;
		   System.out.println(i+" card(s)");	
		
	   }
	 
	 
		
		
		

	}
	public static double newSum(int n)
	{
		
		double sum=0.0;
		for(double i=1.0;i<=n;i++)
		    sum=sum+1/(i+1);
		
		return sum;
		
		
	}

}

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