Posted on 2008-05-08 12:20
superman 阅读(326)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1242 C++ 00:00.00 844K */
2 #include <math.h>
3 #include <iostream>
4
5 using namespace std;
6
7 int main()
8 {
9 int w, d, n = 1;
10 while(cin >> w >> d)
11 {
12 if(w == 0 && d == 0)
13 break;
14
15 double x = log10(d / (w * 810.0)) / log10(0.5) * 5730;
16
17 int ans;
18 if(x <= 10000)
19 {
20 ans = int(x) / 100;
21 if(int(x) % 100 >= 50)
22 ans++;
23 ans *= 100;
24 }
25 else
26 {
27 ans = int(x) / 1000;
28 if(int(x) % 1000 >= 500)
29 ans++;
30 ans *= 1000;
31 }
32
33 cout << "Sample #" << n++ << endl;
34 cout << "The approximate age is " << ans << " years." << endl << endl;
35 }
36
37 return 0;
38 }
39