PersonalCorpus 版 (精华区)
寄信人: ooze (烂泥~苦读武侠中)
标 题: 545
发信站: 哈工大紫丁香 (2002年06月19日15:19:40 星期三)
来 源: 202.118.239.224
Your C++ program has solved Ok the problem 545 (Heads)
in 0.070 seconds with low memory spent.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <ctype.h>
void main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\uva\\input545.txt","r",stdin);
freopen("c:\\uva\\output545.txt","w",stdout);
#endif
int i,j,k,n,tot,y;
double temp;
char s[100];
scanf("%d\n",&tot);
while (tot>0) {
tot--;
if (gets(s)==NULL) break;
while (strlen(s)>0) {
sscanf(s,"%d",&n);
temp=0.30102999566398119521373889472449 * n; // log10(2) *
n
y=ceil(temp);
// printf("2^-%d = %.3fE-%d\n",n,1/pow(10,temp-y),y);
// Error!! printf("2^-%d = %.3lfE-%d\n",n,1/pow(10,temp-y),y);
// Works OK!!
printf ("2^-%d = %.3lfE-%d\n",n,exp(y*log(10)-n*log(2)),y);
if (gets(s)==NULL) break;
}
if (tot>0) printf("\n");
}
}
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.224]
--
※ 转寄:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: 202.118.239.224]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.725毫秒