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

Re:疯了完全没理由啊

Posted by hu_wu at 2014-02-11 09:10:18 on Problem 1003
In Reply To:疯了完全没理由啊 Posted by:ilmlj at 2014-02-05 16:37:30
> 对于第1003题为什么这样是答案是错误的呢??
> 我找了运行可以通过的答案,几乎没差别啊??
> 求教大神啊
> 
> 下面是我的答案:
> public class Main{
> 	public static void main(String[] args){
> 		String str;
> 		float c,sum = 0;
> 		int i;
> 		Scanner scanner = new Scanner(System.in);
> 		str = scanner.nextLine();
> 		while(!str.equals("0.00")){
> 			c = Float.valueOf(str).floatValue();
> 			for(i=1;sum<c;i++){
> 				sum = sum + 1f/(i+1);
> 			}
> 			System.out.printf("%d card(s)\n",i-1);
> 			str = scanner.next();
> 		}
> 		
> 	}
> }
> 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