mydjm

 

poj1003

Input

The input consists of one or more test cases, followed by a line containing the number 0.00 that signals the end of the input. Each test case is a single line containing a positive floating-point number c whose value is at least 0.01 and at most 5.20; c will contain exactly three digits.

Output

For each test case, output the minimum number of cards necessary to achieve an overhang of at least c card lengths. Use the exact output format shown in the examples.

Sample Input

1.00
3.71
0.04
5.19
0.00

Sample Output

3 card(s)
61 card(s)
1 card(s)
273 card(s)
懒得翻译了
 1 #include<stdio.h>
2 int main()
3 {
4 int i;
5 double c;
6 while(scanf("%lf",&c)!=EOF && c!=0.00)
7 {
8 double sum=0.00;
9 for(i=2;sum<c;i++)
10 {
11 sum=sum+1.0/i;
12 }
13 printf("%d card(s)\n",i-2);
14 }
15 return 0;
16 }

这题不难 早做出来了 但在poj上提交还是花了我点时间。。一是标准输入格式while()..不是很了解
然后double类型的scanf格式。。总结下:
一、double类型的scanf格式是“lf”,这个以前还真没试过。。一开始写成“f”导致我wrong answer。。
  还是cin方便 不用考虑这破事。。
二、while(scanf("%lf",&c)!=EOF && c!=0.00) 标准格式 可以借鉴下 百度的~
三、这题是不是有歧义,题目中要求的input格式是连续输入一行或多行数据,
直到输入0.00时结束,并输出结果。。然后我就想着用数组去保存,总是runtime error。。
百度了一下,有篇文章,说已经ac的代码 我看了下 输入格式是进一个出一个 不是题目要求的输一串出一串。。
咋回事。。我也不管了 我也跟着一个进一个出吧。结果ac了~~

posted on 2011-11-26 13:45  mydjm  阅读(1214)  评论(0编辑  收藏  举报

导航