Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 57382 | Accepted: 26983 |
本题是北大oJ上比较水的题目,在给的说明中已经把规律讲明,所以只管写代码即可
可行代码:
1 #include < stdio.h >
2 int main()
3 {
4 double a,s;
5 int n;
6 while (scanf( " %lf " , & a) != EOF)
7 {
8 n = 0 ;s = 0 ;
9 if (a == 0.00 )
10 break ;
11 while (s < a)
12 {
13 n ++ ;
14 s += 1.0 / (n + 1 );
15 }
16 printf( " %d card(s)\n " ,n);
17 }
18 return 0 ;
19 }
20