| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
java 1003 ac codesimport java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int[] card = new int[522];
double sum = 0;
int i = 2;
int j = 1;
int p;
while (sum < 5.21) {
sum += (1/((double)(i)));
p = ((int)(sum * 100));
for (; j <= p; j++) {
card[j] = i - 1;
}
j = p + 1;
i++;
}
int input;
while((input = ((int)(in.nextDouble() * 100))) != 0) {
System.out.println(card[input] + " card(s)");
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator