Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string n;
  8. cin>>n;
  9. int x=n.size();
  10. int b[x];
  11. int a=4*x;
  12. int bin[a];
  13.  
  14.  
  15. for(int i=0;i<a;i++)
  16. {
  17. bin[i]=2;
  18. }
  19.  
  20. for(int i=0;i<x;i++)
  21. {
  22. b[i]=n[i];
  23. b[i]-=48;
  24. }
  25.  
  26. for(int i=a-1;i>=0;i--)
  27. {
  28. if(b[x-1]%2==1)
  29. {
  30. b[x-1]--;
  31. bin[i]=1;
  32. }
  33. else
  34. {
  35. bin[i]=0;
  36. }
  37.  
  38.  
  39. for(int j=0;j<x;j++)
  40. {
  41. b[j+1]+=((b[j]%2)*10);
  42. b[j]/=2;
  43. }
  44. }
  45.  
  46. int tab[202];
  47. for(int i=0;i<201;i++)
  48. tab[i]=0;
  49.  
  50. tab[201]=1;
  51.  
  52. int d=1;
  53.  
  54. bool c=0;
  55.  
  56. for(int i=a-1;i>=0;i--)
  57. {
  58. if(bin[i]==1)
  59. {
  60. for(int j=0;j<202;j++)
  61. {
  62. if((c==0)&&(tab[j]!=0)) c=1;
  63.  
  64. if(c==1) cout<<tab[j];
  65. }
  66. c=0;
  67. cout<<endl;
  68. }
  69.  
  70. if(bin[i]!=2)
  71. {
  72. for(int j=201;j>201-d;j--)
  73. {
  74. tab[j]*=2;
  75. }
  76. for(int j=201;j>201-d;j--)
  77. {
  78. tab[j-1]+=tab[j]/10;
  79. tab[j]=tab[j]%10;
  80. }
  81. if(tab[201-d]!=0)d++;
  82. }
  83.  
  84. }
  85. return 0;
  86. }
  87. //100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  88. //1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  89. //583992399055640987986069965529637289586333248927815671114136642291107221402710705472756839848623539171666215625420084135768154204336056063776340648924443416096255318318113913610607896607565283328
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement