zoj 1242 Carbon Dating
来源:互联网 发布:nat 端口转发 编辑:程序博客网 时间:2024/04/28 02:22
Until the second half of the 20th century, determining the actual age of an archaeological find had been more or less a matter of educated guessing. Comparing finds to previous, already dated, ones and evaluation of the surroundings of a find were the best available techniques.
But nowadays, there is a much more reliable method: carbon dating. Carbon dating works as follows: Naturally occurring carbon is a mixture of stable isotope (mostly 12C) and the unstable, radioactive, isotope 14C. The ratio between the two is almost constant in living organisms: 14C slowly decays, but at the same time, the radiation of the sum produces the same amount in the upper atmosphere, which is taken in by the organisms.
But when, for example, a tree is felled and made to wood, it does not receive any new 14C, and the amount present in the wood becomes less and less due to radioactive decay. In this problem, you are to write a program that uses information about the amount of remaining 14C to determine the approximate age of sample. The following facts must be used:
The amount of 14C present in a sample halves every 5730 years (this is called the half-life of 14C).
The rate of decay (measured in decays per hour per gram of carbon) is proportional to the amount of 14C left in the sample.
In living organisms (age zero), there are 810 decays per hour per gram of carbon.
So, for example, if we measure in a sample of one gram of carbon 405 decays per hour, we know that it is approximately 5730 years old.
Input
The input contains the measurements taken of several samples we want to date. Every line contains two positive integers, w and d. w is the amount of carbon in the sample, measured in grams, and d is the number of decays measured over one hour.
The input is terminated by a test case starting with w = d = 0.
Output
For each sample description in the input, first output the numnber of the sample, as shown in the sample output.Then print the approximate age in the format
The approximate age is x years.
If the age is less than 10,000 years, x should be rounded to the colsest multiple of 100 years (rounding up in case of a tie). If the age is more than 10,000 years, round it to the closest multiple of 1000 years (again rounding up in case of a tie).
Print a blank line after each sample.
Sample Input
1 405
5 175
0 0
Sample Output
Sample #1
The approximate age is 5700 years.
Sample #2
The approximate age is 26000 years.
#include <cstdio>#include <cmath>int w, d;int flag;void solve() { int t; t = (int)(5730 * (log(810.0 * w) - log(d)) / log(2.0)); if (t < 10000) t = (t + 50) / 100 * 100; else t = (t + 500) / 1000 * 1000; printf("The approximate age is %d years.\n", t);}int main() { flag = 1; while (~scanf("%d%d", &w, &d) && w && d) { printf("Sample #%d\n", flag++); solve(); puts(""); }return 0;}
- ZOJ 1242 Carbon Dating
- zoj 1242 Carbon Dating
- zoj 1242 Carbon Dating
- ZOJ 1242 Carbon Dating
- zoj 1242 Carbon Dating
- ZOJ 1242 Carbon Dating
- ZOJ 1242 Carbon Dating
- zoj 1242 Carbon Dating
- zoj 1242 Carbon Dating
- zoj 1242 Carbon Dating
- zoj 1242 Carbon Dating 纠结
- zoj 1242 Carbon Dating(math)
- fjnu 1671 Carbon Dating
- zoj1242——Carbon Dating
- ZOJ_1242_Carbon Dating
- PAT_1061: Dating
- 1061. Dating
- 1061.Dating
- git server简易部署方案
- 关于孔浩老师的CMS项目无法启动问题的解决方案
- Ubuntu Linux 切换为root用户的方法
- JavaScript prototype
- 事务可重复读
- zoj 1242 Carbon Dating
- Android SDK环境变量配置
- 使用SVN进行多版本开发教程
- C++中头文件相互包含的几点问题
- java.lang.UnsupportedClassVersionError
- 数据库oracle--PL/SQL的使用-禁止生成备份文件 .~sql
- 七巧板平台html5游戏开发之初识物理引擎
- 安卓Adapter用法
- 【小功能2】android获取手机信息(号码,内存,CPU,分辨率,MAC,IP,SD卡,IMEI,经纬度,信号强度等等)