Advertisement
Mahfuz123

Problem 42

May 26th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main()
  5. {
  6. int n,i,j,a,b,c,d;
  7.  
  8. scanf("%d",&n);
  9.  
  10. if(n<=100){
  11. for(i=1;i<=n;i++){
  12. scanf("%d",&a);
  13.  
  14. if(a<=50){
  15. for(j=a;j>=0;j--){
  16. d = pow(2,j);
  17.  
  18. if(j>=2){
  19. printf("2^%d + ",j);
  20. }
  21.  
  22. else if(j==1){
  23.  
  24. printf("%d + ",d);
  25. }
  26. else if(j==0){
  27. printf("%d\n",d);
  28. }
  29. }
  30. }
  31.  
  32. }
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement