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

this is ridiculous

Posted by pansophism at 2011-05-13 13:44:39 on Problem 1003
WA for no reason?


import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		float in = 0.0f;
		while ((in = cin.nextFloat()) != 0.0) {
			System.out.println(getCards(in) + " cards(s)");
		}
	}

	private static int getCards(float in) {
		float n = 0;
		while(in > 0){
			in -= 1/(++n + 1);
		}
		return (int) n;
	}
}

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