Saleh127

UVA 474

Aug 4th, 2021 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  5.  
  6. double f3[1000005];
  7.  
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(0);
  11. cin.tie(0);cout.tie(0);
  12.  
  13.  
  14. f3[0]=1;
  15.  
  16. for(int i=1;i<=1000000;i++)
  17. {
  18. f3[i]=f3[i-1]*5;
  19.  
  20. while(f3[i]>=10)
  21. {
  22. f3[i]/=10;
  23. }
  24. }
  25.  
  26. int n,digit;
  27.  
  28. while(cin>>n)
  29. {
  30. digit=n*log10(2)+1; ///number of digit in 2^-n;
  31.  
  32. cout<<"2^-"<<n<<" = "<<fixed<<setprecision(3)<<f3[n]<<"e-"<<digit<<endl;;
  33. ///pow(10, log10(2)*(-n)-digit);
  34. }
  35.  
  36. return 0;
  37. }
  38.  
Add Comment
Please, Sign In to add comment