superman

聚精会神搞建设 一心一意谋发展
posts - 190, comments - 17, trackbacks - 0, articles - 0
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

ZOJ 1242 - Carbon Dating

Posted on 2008-05-08 12:20 superman 阅读(315) 评论(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 

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理