当前位置: 代码迷 >> 综合 >> ZOJ 1242
  详细解决方案

ZOJ 1242

热度:34   发布时间:2024-01-11 16:43:18.0
//半衰期log2  ?
//代码参考网上的,用到了换底公式
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{int w, d, cout = 1;int dec = 5730, result;double temp, year;while( scanf( "%d%d", &w, &d )!= EOF && w ){temp = 810.0*w/d;year = 5730 * log(temp)/log(2);if( year < 10000 ){result = 100*(int)(year/100 + 0.5);}else{result = 1000*(int)(year/1000 + 0.5);}printf("Sample #%d\nThe approximate age is %d years.\n\n",cout++, result);}return 0;
}