Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef int nrmare[100005];
  5.  
  6. void atrib(nrmare x, int n)
  7. {
  8. x[0]=0;
  9. if(n==0)
  10. x[(x[0]=1)]=0;
  11. else
  12. for(; n; n/=10)
  13. x[++x[0]]=n%10;
  14. }
  15. void sum(nrmare x,nrmare y)
  16. {
  17. int t=0;
  18. y[0]=1;
  19. for(int i=1;i<=x[0];i++)
  20. {
  21. t+=x[i];
  22.  
  23. y[y[0]]+=t%10;
  24. if(t>=10) y[0]++;
  25. t/=10;
  26. }
  27. if(t)
  28. y[++y[0]]=t;
  29. }
  30. int prim(int a)
  31. {
  32. if(a<2)
  33. return 0;
  34. if(a==2)
  35. return 1;
  36. for(int j=2; j*j<=a; j++)
  37. {
  38. if(a%j==0)
  39. return 0;
  40. }
  41. return 1;
  42. }
  43. void produs(nrmare x, int y)
  44. {
  45. int i,t=0;
  46. for(i=1; i<=x[0]; i++,t/=10)
  47. {
  48. t+=x[i]*y;
  49. x[i]=t%10;
  50. }
  51. for(; t; t/=10)
  52. {
  53. x[++x[0]]=t%10;
  54. }
  55. }
  56. int ok1=0;
  57. int n;
  58. int main()
  59. {
  60. int k;
  61.  
  62. cin>>k;
  63. if(k==1)
  64. cout<<2;
  65. else
  66. {
  67. nrmare summ;
  68. nrmare z;
  69. atrib(z,2);
  70. int rest=k%10;
  71. int y=k/10;
  72. int l=1;
  73. for(int i=1; i<rest; i++)
  74. l*=2;
  75. produs(z,l);
  76. for(int i=1; i<=y; i++)
  77. produs(z,1024);
  78. atrib(summ,0);
  79. sum(z,summ);
  80. for(int i=summ[0];i>=1;i--)
  81. cout<<summ[i];
  82. }
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement