想吃冰卻又敏感保護不足?直擊★美車模手癢不小心...正妹的東京自助旅行黃曉明、林志玲攜手代言...
2012-05-13 16:44:09 人氣(263) | 回應(0) | 推薦(0) | 收藏(0) 上一篇 | 下一篇

[UVA][Math] 545 - Heads

0
收藏
0
推薦


 Heads 

The probability of n heads in a row tossing a fair coin is 2-n

Input 

The first line of the input contains an integer r. Then r lines containing each one an integer number n. The valueof n is as follows:$0< n le 9000$.

Output 

Print r lines each with the value of 2-n for the given values of n, using the format:


2^-n = x.xxxE-y


where each x is a decimal digit and each y is a decimal integer with no leading zeroes or spaces.

Sample Input 

3
8271
6000
1

Sample Output 

2^-8271 = 1.517E-2490
2^-6000 = 6.607E-1807
2^-1 = 5.000E-1



#include <stdio.h>
#include <math.h>
int main() {
int t, n;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
int e = (int)floor(-n*log10(2));
printf("2^%d = %.3lfE%d\n", -n, pow(10, -n*log10(2)-e), e);
}
return 0;
}

545Heads
台長:Morris
人氣(263) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: UVA |
此分類下一篇:[UVA][最小覆蓋圓] 10005 - Packing polygons
此分類上一篇:[UVA][二分圖] 11045 - My T-shirt suits me

我要回應
是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入以下數字 (ex:123)

(有*為必填)
詳全文