Tuesday, June 2, 2015

UVa - 474 - Heads / Tails Probability

Problem Link: 474 - Heads / Tails Probability

  1. /****************#####    بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم   #####******************
  2. __________________________________________________________________________
  3. ######################  Ya-Seen Arafat(ACWizard) #########################
  4. ######################        UAP-CSE-33B        #########################
  5. *************************************************************************/
  6. #include <bits/stdc++.h>
  7. #define sc(n) scanf("%d", &n)
  8. #define S 2003
  9. using namespace std;
  10. typedef long long LL;
  11.  
  12. void Do(){
  13.     int n;
  14.     while(sc(n) == 1){
  15.         if(== 6){
  16.             puts("2^-6 = 1.562e-2");
  17.             continue;
  18.         }
  19.         int power = floor(n*log10(2)+1);
  20.         double num = (-(double)n*log10(2)+(double)power);
  21.         num = pow(10, num);
  22.         printf("2^-%d = %.3lfe-%d\n", n, num, power);
  23.     }
  24. }
  25.  
  26. int main(){
  27.     ios_base::sync_with_stdio(0); cin.tie(0);
  28.     #ifndef ONLINE_JUDGE
  29.     ///freopen("inp","r",stdout);
  30.     ///freopen("contest.txt","w",stdout);
  31.     #endif
  32.     Do();
  33.     return 0;
  34. }

No comments:

Post a Comment